MATLAB: Simple quastion about randn and mean of random noise

communicationgaussiannoiserandom

hi, i'm a bit confused and need your help.
i know that mean(sum(n))=sum(mean(n)) where n is a random noise with zero mean and N0 variance.
but when im writing : n=randn(1000,1)
mean(sum(n))=-32…. sum(mean(n))=~0
whats the diference and how its get along with E(sum(n))=sum(E(n))??
thanks in advance…

Best Answer

The variable n is a column vector of 1000 instances of a Random Variable of mean 0 and variance 1.
In the first case, if you take the sum of a column vector, it returns a single value, which is simply the sum across all 1000 elements of the column vector. If you take the mean of a single value, you will get the value itself, which in this case is ~32.
In the second case, if you take the mean of 1000 values, it will return a single value that represents the arithmetic average of those 1000 values. Since you generated them from a Random Variable with mean 0, it should be approximately 0. If you then sum across that single value, you will again get the same value, which is ~0.
So the results you are describing are expected.
I think what you may want to do is to create a matrix of randomly generated values, and then try the same experiment where you treat each column of the matrix as a separate trial, with each trial drawing 1000 values from your random variable.
So please try the following:
X = randn(1000,200);
and then repeat the test.
HTH.
Rick