Simulating from multivariate normal

Ajay Shah
Sat Jan 18 16:00:00 GMT 2003

From: Przemyslaw Sliwa <>
> Subject: Multivariate Normal
> I wanted to ask You how to simulate the multivariate normal
> distribution.  I need a vector X which is multivariate normally
> distributed with E(X)=0 and the I - matrix as a covariance. So the
> components of X are uncorrelated and have the variance equal one. I
> know that even if the components of X have marginal normal
> distribution the vector X can have a normal distribution which is
> different than the multivariate normal distribution.

Nothing GSL about this, but here goes.

Suppose you want to simulate from N(mu, S) where S is the covariance
matrix. A general plan is to compute the cholesky decomposition S=TT'
and then given a vector of z ~ N(0,I), the vector T'z + mu ~
N(mu,S). This works because if z ~ N(0,I), Tz has covariance matrix
TIT' or S.

Now your question was more basic - you were asking: How do I simulate
from N(0,I). For this, just generate a collection of N(0,1) scalars
and stack them into a vector. They are i.i.d. and you're through.

Hope this helps,


Ajay Shah                                 
Department of Economic Affairs,
Ministry of Finance, New Delhi

More information about the Gsl-discuss mailing list