Probability distributions
Multivariate normal log density
prob.multivariate-normal-logpdfAlso called multivariate normal logpdf, mvn logpdf, gaussian log likelihood, multivariate gaussian log density
Natural log of the density of a d-dimensional normal distribution with mean μ and covariance Σ.
Notation
the point
x ∈ ℝd
mean vector
μ ∈ ℝd
covariance matrix, symmetric positive definite
Σ ∈ ℝd×d, symmetric positive definite
dimension
Size, at least 1
Result: the log density at x
scalar
Worked examples
Each result is solved exactly and confirmed by two independent computations.
Given
Result
≈ -1.4189385332
Given
Result
≈ -4.43445065669
Given
Result
≈ -2.72051654408
Given
Result
≈ -3.03102424697
Common mistakes
Uses Σ where Σ−1 belongs
The quadratic form multiplies by the covariance instead of its inverse.
Fix: Solve Σv = (x − μ) and use (x − μ)Tv.
Omits the ln det Σ term
The normalizing term −½ ln det Σ is missing.
Fix: Subtract ½ ln det Σ.
Subtracts ln det Σ without the factor ½
The determinant term is doubled, as when ln det of a Cholesky factor is confused with ln det Σ.
Fix: Subtract ½ ln det Σ, which equals the sum of ln Lii for the Cholesky factor L.
Sources
Bishop 2006
Bishop, Christopher M. Pattern Recognition and Machine Learning. Springer, 2006.
Murphy 2022
Murphy, Kevin P. Probabilistic Machine Learning: An Introduction. MIT Press, 2022.