Generate Correlated Normal Random Variables
If you need to generate $n$ correlated Gaussian distributed random variables $$ \bf Y \sim \mathcal N(\bf \mu, \Sigma) $$ where $\textbf{Y} = (Y_1,\dots,Y_n)$ is the vector you want to simulate, $\mu =(\mu_1,\dots, \mu_n)$ the vector of means and $\Sigma$ the given covariance matrix,
- you first need to simulate a vector of uncorrelated Gaussian random variables, $\bf Z $
- then find a square root of $\Sigma$, i.e. a matrix $\bf C$ such that $\bf C \bf C^\intercal = \Sigma$.
Your target vector is given by $$ \bf Y = \bf \mu + \bf C \bf Z. $$
A popular choice to calculate $\bf C$ is the Cholesky decomposition.