Multivariate gaussian distribution

I have a 300-D mean vector and a 300x300 covariance matrix and want to compute a Gaussian distribution of the same. The problem that I am facing, computing it manually is that the determinant is always computed as 0 as its a product of 300 weak numbers b/w 0 and 1. Is there a way to avoid this … or a function to do the same?


I don’t know well but am just curious about if torch.distributions.MultivariateNormal is enough.

You could try working in log space (i.e. log(det(Sigma))), which typically results in much better stability when working with products of small numbers.

In the case of a diagonal covariance matrix, the log determinant is the sum of the log of each diagonal element.