This article describes common methods that are used in generating correlated random numbers.
Contents
1 Generating two sequences of correlated random numbers
1.1 Before and after correlating
2 Generating multiple (more than two) sequences of correlated random variables
2.1 Example using a Cholesky decomposition
2.2 Example using a Eigenvector decomposition
Generating two sequences of correlated random numbers
Generating two sequences of random numbers with a given correlation is done in two simple steps:
Generate two sequences of uncorrelated normal distributed random numbers
Define a new sequence 
This new
sequence will have a correlation of
with the
sequence.
[edit] Before and after correlating
Generating multiple (more than two) sequences of correlated random variables
A general way to generate correlated (normal distributed) random numbers -with a given correlation matrix
- is done by finding a matrix U such that

Using this matrix, one can generate correlated random numbers
from uncorrelated numbers
by multiplying them with this matrix.

There are multiple way to find such a matrix. The two most common methods are
A Cholesky decomposition of the correlation matrix
An Eigenvector decomposition of the correlation matrix (also known as a spectral decomposition)
Example using a Cholesky decomposition
We want to generate random numbers for three variables with the following correlations matrix:

Doing a Cholesky decomposition on the correlation matrix give the following matrix:

Depending on the algorithm used for the Cholesky decomposition, you can also get the transposed of this matrix. This does doesn’t matter.
We can now transform three uncorrelated random numbers

into correlated numbers Rc by multiplying them with the U matrix.



[edit] Example using a Eigenvector decomposition
The correlation matrix
has the following eigenvectors

and eigenvalues

If we define

we get a matrix
that has the property

which gives us the final result for the decomposition

We can now transform three uncorrelated random numbers

into correlated numbers Rc by multiplying them with the U matrix.

[edit] Example Matlab code
The matlab code below decomposes the correlation matrix C into an upper matrix U using a Cholesky decomposition. Next 10 vectors with 3 random normal numbers are multiplied with the upper matrix to generate 10 correlated draws.
>> C= [ 1.0 0.6 0.3; 0.6 1.0 0.5; 0.3 0.5 1.0]
C =
1.0000 0.6000 0.3000
0.6000 1.0000 0.5000
0.3000 0.5000 1.0000
>> U = chol(C)
U =
1.0000 0.6000 0.3000
0 0.8000 0.4000
0 0 0.8660
>> randn(10,3)*U
ans =
-0.4326 -0.4089 0.0505
-1.6656 -0.4187 -1.3665
0.1253 -0.3955 0.4209
0.2877 1.9192 2.3656
-1.1465 -0.7970 -0.9976
1.1909 0.8057 1.1459
1.1892 1.5669 1.8695
-0.0376 0.0248 -1.3678
0.3273 0.1199 -1.1880
0.1746 -0.5611 0.2141










0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.