1
votes

I had a question regarding the randn function in matlab.

"randn generates random numbers and matrices whose elements are normally distributed with mean 0 and variance 1."

I got this off a website: http://www.math.ufl.edu/help/matlab/randn.html

I just wanted to know if this means that the mean and variance of any randn matix or randn vector generated will be 0 and 1 respectively?

Thanks

1

1 Answers

4
votes

I would say that the "population" mean is zero and std is one, but the sample mean and std can have some error and so won't be exact. The bigger the sample,the smaller the error therefore the closer to the values of 0 and 1. Try this to illustrate this to yourself:

n = randn(10,1);
N  = randn(1000000,1);

mean(n)
std(n)

mean(N)
std(N)

As Marc Claesen points out, if we were to guarantee that the sample mean and std are 0 and 1 then the sample itself cannot be truly random. To guarantee a mean of zero for example, once the first 9 out of 10 samples have been generated, the 10th number cannot be chosen at random as there is only one number that can make the sample mean zero. It is unique and can be solved for deterministicly and thus the sample is no longer random.