how to generate two uncorrelated gaussian random variables

7 views (last 30 days)
i tried to generate two uncorrelated random process which i tried like this
x1=random('Normal',0,1,1,N);
x2=random('Normal',0,0.5,1,N);
is this right. pls help me. thanks in advance

Answers (1)

the cyclist
the cyclist on 25 Feb 2014
Edited: the cyclist on 25 Feb 2014
That is one way to generate uncorrelated random normals.
Another would be to use the randn() command.
  3 Comments
Walter Roberson
Walter Roberson on 20 Jul 2023
format long g
N = 1e7;
X = randn(N,1);
Y = randn(N,1);
R = corrcoef(X, Y)
R = 2×2
1 -0.000347360611933317 -0.000347360611933317 1
The anti-diagonal is not zero, but it is not large either.
The default random number generator MT19937 has a very long period, and are considered to pass the https://en.wikipedia.org/wiki/Diehard_tests
This does not mean that values from randn() are completely uncorrelated -- but the correlation is low. For example it would not astonish me if the correlation were on the order of 2^-sqrt(19937) which would be roughly 3.8 * 10^-43
the cyclist
the cyclist on 26 Jul 2023
@Kavya, be aware that finite samples from two independent parent distributions will typically have some correlation. It is essentially a type of sampling error.
This is a similar phenomenon, conceptually, to tossing N fair coins and realizing that you would not expect exactly N/2 heads every time.

Sign in to comment.

Categories

Find more on Random Number Generation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!