title: Most efficient way of calculating multivariate Gaussian probability for a large matrix
body: <p>I have a big matrix (3 x 800,000), and I need to calculate the multivariate Gaussian probability density, given by: </p>
  
  <p><a href="https://i.stack.imgur.com/o0sw9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o0sw9.png" alt="Multivariate Gaussian Probability Density Function"></a></p>
  
  <p>I was wondering how to do this efficiently. I already have the mean and covariance matrices, and I need to do it column-wise (so 800,000 times).</p>
  
  <p>I have been doing it in for loops but it takes a lot of time. I also tried list comprehensions but didn't improve the time by too much.</p>
  
  <p>I forgot to mention it before, but I can't use any built-in normal functions, I have to use my own multivariate normal function.</p>