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$?
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.