generating correlated random variables - cornell...
TRANSCRIPT
Generating Correlated Random Variables
Bivariate Gaussian Distribution
The joint (bivariate) PDF for X1,2 is
fX1X2(x1, x2) =1
2π
1
(1− ρ2)1/2exp
− 1
2(1− ρ2)
x21σ21
+x22σ22− 2ρ
x1x2σ1σ2
A more useful of writing this PDF is to use the column vector X = col (X1, X2) and thecovariance matrix
C =
σ21 σ1σ2ρ
σ1σ2ρ σ22
to write (using † to denote transpose)
fX(X) =1
2π(detC)1/2exp
−12X†C−1X
.
The bivariate Gaussian is used frequently in likelihood and Bayesian estimation to displaycontours for parameter estimates.
1
Figure 1: Scatter plots of two random variables X1,2 that have a joint Gaussian PDF for four different values of correlation coefficient, ρ.
2
Generating Correlated Random Variables
Consider a (pseudo) random number generator that gives numbers consistent with a 1D Gaus-sian PDF ≡ N(0, σ2) (zero mean with variance σ2).
How do we create two Gaussian random variables (GRVs) from N(0, σ2) but that are correlatedwith correlation coefficient ρ?
So we wantρX1,X2 =
〈(X1 − 〈X1〉) (X2 − 〈X2〉)〉σ2
.
Define Y1, Y2 as independent N(0, σ2) GRVs, so ρY1,Y2 = 0 and let
X1 = aY1 + bY2
X2 = cY1 + dY2.
Since the means of all variables are zero, we have
〈X1X2〉 = 〈(aY1 + bY2)(cY1 + dY2)〉= ac〈Y 2
1 〉 + bd〈Y 22 〉 + (ad + bc)〈Y1Y2〉
= (ac + bd)σ2
ThereforeρX1X2 =
〈X1X2〉σ2
= ac + bd (1)
3
We also want〈X2
1〉 = (a2 + b2)σ2 = σ2
〈X22〉 = (c2 + d2)σ2 = σ2
so
a2 + b2 = c2 + d2 = 1 (2)
A natural solution is to use a = cosφ b = sinφ
c = sinφ d = cosφ.
Then the constraint equations (1) and (2) are satisfied and
ac + bd = ρX1X2 = 2 cosφ sinφ = sin 2φ
soφ =
1
2sin−1 ρX1X2.
4