# Multivariate normal distribution from invertable covariance matrix

I want to generate a random vector with $\mathcal{N}(0, C)$ distribution, i.e. normal distribution with $0$ mean and given covariance matrix $C$.

$C$ is not invertible (singular). Here it's written:

The covariance matrix is allowed to be singular (in which case the corresponding distribution has no density). This case arises frequently in statistics (...)

So, how can I do it without inverting $C$?

• You mean not invertible. Oct 27, 2013 at 21:50
• @RobertIsrael Yes, thank you. Oct 27, 2013 at 21:56

We are looking for a vector $BX$ with covariance matrix $C$.

$C[BX]=E(BX⋅BX^T)=E(BX⋅X^T⋅B^T)= B⋅E(XX^T)⋅B^T = BIB^T = BB^T$

So, we get matrix $B$ straight from matrix $C$, decomposing it to $BB^T$.

For this we can use LU decomposition or, when $C$ is positive definite, Cholesky decomposition.

Hint: if $B$ is a matrix and $X$ is a normal random vector with covariance matrix $I$, what is the covariance matrix of $BX$?

• Is it simply $BI$? Oct 27, 2013 at 22:34
• No, it isn't. Use the definition of covariance matrix in terms of expected value. Oct 27, 2013 at 22:41
• I don't know how to calculate covariance matrix of a... matrix, which $BX$ unfortunately is... Oct 27, 2013 at 23:48
• $X$ is a vector. $B$ is a matrix. $BX$ is a vector (it is assumed that the sizes are appropriate so the multiplication can be done). Oct 28, 2013 at 0:01
• $\mathbf{C}[BX] \triangleq E\{(\mathbf{BX}-\bar{\mathbf{BX}})(\mathbf{BX}-\bar{\mathbf{BX}})^T\}$ But I don't know what next. Oct 28, 2013 at 13:27