Generating a string of random standard normal variables that are correlated

24 views (last 30 days)
Hi Everyone,
I'm a sort of newbie, I would like to know how and what the implications are of 'Generating a string of random standard normal variables that are correlated with each other'.
To get by this problem, I have been generating and correlating my desired sequence to a different random variable and then calculating the correlation between my sequence.
Thanks for the anticipated answer.
ps: Generate random standard normal's A, B, C, D so that have a correlation and standard deviation of corr and std.
Thanks again

Accepted Answer

Daniel Shub
Daniel Shub on 6 Dec 2011
I am not sure if this is homework or not ...
Start off with two independent random variables with zero mean and standard deviation sigma.
sigma = 10;
X = sigma*randn(1e7, 1);
Y = sigma*randn(1e7, 1);
Then make two new random variables from these with correlation rho.
rho = 0.2;
A = X;
B = sqrt(rho^2)*X+sqrt(1-rho^2)*Y;
[std(A), std(B)]
corrcoef(A, B)
When you add a third random variable C you need to specify what you want rho_AB, rho_AC, and rho_AB to be. The basic idea is the same: start with N independent random variables and add them together with appropriate weighting to get N new random variables.
Alexander Knetsch
Alexander Knetsch on 10 Nov 2020
The equation is quite good already, it doesn't allow for a negative corellation. If you change the expression for B, you can allow for this:
B = (rho/abs(rho))*sqrt(rho^2)*X+sqrt(1-rho^2)*Y;

Sign in to comment.

More Answers (2)

Oleg Komarov
Oleg Komarov on 6 Dec 2011
Given a correlation matrix C = A*A', then A = P*sqrt(D), where:
[P,D] = eig(C); % spectral decomposition
To get the correlated normal random series Z, use W = (W1, ...,W2)' (the normal random series):
Z = A*W;
Note that if you have 4 variables, then C is 4 by 4, and W should be 4 by nobs.
  1 Comment
Natialol on 6 Dec 2011
I'm trying to read up on the answer and will accept as soon as I understand that it does the above. Please can you also comment on the above question to Daniel?

Sign in to comment.

Chet Sharma
Chet Sharma on 30 Jan 2018
I think you should refer Hull's option book. In the 8th edition, chapter 20, page 450, I believe you will find out answer. He describes something called a "Cholesky decomposition" that is needed to generate the "correct" correlation matrix......


Find more on Descriptive Statistics 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!