How to use covar in random number generation?
"Mike Middleton" wrote:
Browse to Google Groups and search for "excel correlated
normal random" (without the quotes)
I am glad I got your attention, too :-).
Thanks. That does indeed provide more useful hits than
the google search I had done earlier. It finds some useful
papers, which I have yet to read -- including one that I
had failed to bookmark some months ago and could not
find again :-). And I am still plowing through the results
to see if there are any other useful hits.
In the meantime, I am particularly interested in the method
you suggested in Jan05. It is simple enough even for me :-).
Can you answer some questions?
To generate random values from two correlated normal
distributions X and Y, you suggested:
z1 = norminv(rand(), 0, 1)
z2 = norminv(rand(), 0, 1)
x = meanX + stdevX*z1
y = meanY + stdevY*(z1*r + z2*sqrt(1-r^2))
1. Did I translate your formulas correctly? I changed the
notation slightly.
2. Does this method have a common name (a la "Box-Mueller"
or "polar method")? It would be useful to know for my
own documentation as well as if/when I discuss it with
others.
3. I believe "rho" is sqrt(rsq(X,Y)) -- i.e. pearson(X,Y).
Right? You had noted that "rho" must be between -1
and +1.
4. I believe the above works well for two random variables.
What about for N random variables, N = 3?
For example, for random variables X1, X2, X3 and X4,
would I compute simply:
z1 = norminv(rand(), 0, 1)
z2 = norminv(rand(), 0, 1)
z3 = norminv(rand(), 0, 1)
z4 = norminv(rand(), 0, 1)
x1 = meanX1 + stdevX1*z1
x2 = meanX2 + stdevX2*(z1*rX12 + z2*sqrt(1-rX12^2))
x3 = meanX3 + stdevX3*(z1*rX13 + z3*sqrt(1-rX13^2))
x4 = meanX4 + stdevX4*(z1*rX14 + z4*sqrt(1-rX14^2))
where, "rX12" is "rho" for X1 and X2; "rX13" is "rho" for
X1 and X3; etc.
The choice of the correlation with X1 for all cases seems
somewhat arbitrary. I wonder if there are more terms or
more complex terms in the multivariate case, or if the
algorithm should be embellished in some other way.
Thanks again for the pointer (google search).
|