Vous êtes sur la page 1sur 4

# Generating Correlated Random Variables

## Bivariate Gaussian Distribution

The joint (bivariate) PDF for X1,2 is
2
x22
  
1 1 1  x1 x1x2 
fX1X2 (x1, x2) = exp − + − 2ρ

2π (1 − ρ2)1/2 ρ ) σ12
2 σ22
 
2(1 − σ1 σ2
A more useful of writing this PDF is to use the column vector X = col (X1, X2) and the
covariance matrix 
2

σ1 σ1 σ2 ρ 

C= 

2 
σ1 σ2 ρ σ2

1 1
 

## fX(X) = exp − X† C−1 X .

2π(det C)1/2 2

The bivariate Gaussian is used frequently in likelihood and Bayesian estimation to display
contours 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 correlated
with correlation coefficient ρ?
So we want
h(X1 − hX1i) (X2 − hX2i)i
ρX1,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
hX1X2i = h(aY1 + bY2)(cY1 + dY2)i
= achY12i + bdhY22i + (ad + bc)hY1Y2i
= (ac + bd)σ 2
Therefore
hX1X2i
ρX 1 X2 = = ac + bd (1)
σ2
3
We also want
hX12i = (a2 + b2)σ 2 = σ 2
hX22i = (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 −1
φ= sin ρX1X2 .
2