2
votes

I am using matlab's randn function to generate random random numbers from a standard normal distribution. I could see this example in the help

r = 1 + 2.*randn(100,1);

It says that it draws numbers from the normal distribution with mean 1 and standard deviation 2. However, when I calculate the mean of r. It is around 0.77. So I am a bit confused. Can anyone please explain?

1

1 Answers

3
votes

The arithmetic mean (sample mean) will converge to the actual mean of the distribution as the number of samples approaches infinity. However, for any finite number of samples, you're not guaranteed to get the actual mean of the distribution (i.e., 1.0.)

Try

   r = 1 + 2.*randn(100,1);  mean(r)
   r = 1 + 2.*randn(1000,1);  mean(r)
   r = 1 + 2.*randn(10000,1);  mean(r)
   r = 1 + 2.*randn(100000,1);  mean(r)

etc. and see what happens.