gernerating standard normal variable in matlab
Mostrar comentarios más antiguos
I want to generate a vector 'z' of standard normal variable of size n. I want to create a matrix by multiplying z and z transpose, i.e. a=zz'. the matrix a should be ideally a unit matrix of size(n,n). I want to check wether the matrix is close to identity or not ?.
n = 10; % Specify the size of the vector and matrix
z= normrnd(1,0,[n,n]); % Generate a vector of standard normal variables
a = z * z'; % Compute the matrix by multiplying z and its transpose
threshold = 1e-6; % Define a threshold for closeness
norm_diff = norm(a - eye(n), 'fro'); % Compute the Frobenius norm of the difference
if norm_diff < threshold
disp('The matrix a is close to the identity matrix.');
else
disp('The matrix a is not close to the identity matrix.');
end
at what value of n will i get the value close to identity?
The MATLAB command says that :
r = normrnd(mu,sigma,sz1,...,szN) generates an array of normal random numbers, where sz1,...,szN indicates the size of each dimension.
help normrnd
Respuesta aceptada
Más respuestas (1)
John D'Errico
el 10 de Jun. de 2023
I'm a little confused. Why would you expect the result (of z*z') would be even remotely close to an identity matrix? In fact, your claim the result should be any kind of unit matrix would be wrong.
First of all, this is NOT even true:
z= normrnd(1,0,[n,n]); % Generate a vector of standard normal variables
z =
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
a =
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
that does NOT generate a vector of standard normal variates. It generates an array of size 10x10, with mean 1, and standard deviation ZERO. So when you do that, you get an array of all ONES. And therefore, the array a will be an array of all 10's.
But even if you DID generate an array of normal variates, z*z' would still NOT generate anything close to an identity matrix.
I think you are a little confused in this.
3 comentarios
rakesh kumar
el 10 de Jun. de 2023
rakesh kumar
el 10 de Jun. de 2023
Editada: Image Analyst
el 10 de Jun. de 2023
rakesh kumar
el 10 de Jun. de 2023
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!