This quick blog entry to share an excellent article of Thijs van den Berg entitled Generating Correlated Random Numbers.
This author describes in a nicely way how to generate sequences of correlated random numbers using the Cholesky decomposition, and a Eigenvector decomposition as well. (I worked out matrices with QuantLib some time ago.) A piece of Matlab code follows.
This short article is a good opportunity for the reader to get back to some essential statisticals tools/concepts, such as Eigenvectors and Eigenvalues. One can have a look at MathWorld, for example.
The reader like myself that doesn’t have a Matlab license might be tempted to write equivalent code in R language. I recommend the Matrix Algebra in R documentation if you need a refresh on matrices using R.
Example R code using a Cholesky decomposition:
In-a-shot, the code corresponding to the Matlab snippet of the original article might be as follows :