What can I do in case Gram matrix is not positive definite?

Another natural solution is tweaking the Cholesky factorization routine so that when it encounters a negative diagonal element A_{k,k} it replaces A_{k:n, k:n} with zeros and stops. This should let you draw samples from the distribution, since all you need is a low-rank factor (even if it is not strictly positive definite).

This approach has the benefit that it does not need to set a ‘magic’ threshold value, and that it works also in the case where your vectors are dependent and the covariance matrix is positive semidefinite only.

2 Likes