St · Statistics & Probability

How Is the Multivariate Gaussian Density Derived?

Published By the 9to5Science editorial team

At a glance

  1. 1. Start with standard normals

    Use the density of a vector whose coordinates are independent standard normal variables.

  2. 2. Apply an affine map

    Transform that vector so its mean is the desired mean and its covariance is the desired matrix.

  3. 3. Track the Jacobian

    The change of variables contributes the square root of the covariance determinant.

  4. 4. Rewrite the exponent

    Express the transformed squared length using the inverse covariance matrix.

A multivariate Gaussian, or multivariate normal, distribution describes a random vector using a mean vector and a covariance matrix. Its density is the higher-dimensional counterpart of the familiar one-dimensional normal density.

The formula follows directly from a change of variables: start with independent standard normal coordinates, transform them to have the desired covariance, and shift them to the desired mean. The determinant in the density comes from the change in volume under that transformation.

The multivariate Gaussian density

Let XX be a multivariate normal random vector in Rd\mathbb{R}^d with mean vector μ\mu and positive-definite covariance matrix Σ\Sigma. Its density at x∈Rdx\in\mathbb{R}^d is

fX(x)=1(2π)d/2det⁡Σexp⁡(−12(x−μ)TΣ−1(x−μ)).f_X(x)=\frac{1}{(2\pi)^{d/2}\sqrt{\det\Sigma}}\exp\left(-\frac12(x-\mu)^T\Sigma^{-1}(x-\mu)\right).

Here, dd is the number of dimensions, Σ−1\Sigma^{-1} is the inverse covariance matrix, and det⁡Σ\det\Sigma is its determinant. The exponent contains the squared Mahalanobis distance from xx to the mean. Unlike ordinary squared distance, this measure accounts for the variables’ different scales and their correlations.

The condition that Σ\Sigma be positive definite ensures it is invertible and that the multivariate normal distribution has an ordinary density over all of Rd\mathbb{R}^d.

Derivation by change of variables

Let Z=(Z1,…,Zd)TZ=(Z_1,\ldots,Z_d)^T, where the coordinates are independent standard normal variables. Its joint density is the product of the one-dimensional densities:

fZ(z)=(2π)−d/2exp⁡(−12zTz).f_Z(z)=(2\pi)^{-d/2}\exp\left(-\frac12 z^Tz\right).

Choose a nonsingular matrix AA such that AAT=ΣAA^T=\Sigma. Such a matrix exists for every positive-definite covariance matrix; a Cholesky factor is a common choice. Define

X=μ+AZ.X=\mu+AZ.

This transformation gives XX mean μ\mu and covariance AIAT=ΣA I A^T=\Sigma. To find its density, solve for zz:

z=A−1(x−μ).z=A^{-1}(x-\mu).

The change-of-variables formula multiplies the density by the absolute Jacobian determinant. Since the derivative of zz with respect to xx is A−1A^{-1}, that factor is ∣det⁡A−1∣=1/∣det⁡A∣|\det A^{-1}|=1/|\det A|. Also,

det⁡Σ=det⁡(AAT)=(det⁡A)2,\det\Sigma=\det(AA^T)=(\det A)^2,

so ∣det⁡A∣=det⁡Σ|\det A|=\sqrt{\det\Sigma}. The exponent transforms as

zTz=(x−μ)T(A−1)TA−1(x−μ)=(x−μ)TΣ−1(x−μ),z^Tz=(x-\mu)^T(A^{-1})^TA^{-1}(x-\mu)=(x-\mu)^T\Sigma^{-1}(x-\mu),

because (A−1)TA−1=(AAT)−1=Σ−1(A^{-1})^TA^{-1}=(AA^T)^{-1}=\Sigma^{-1}. Substituting the exponent and Jacobian into the standard normal density gives the stated formula.

Worked two-dimensional example

Consider a bivariate normal vector with

μ=(1−1),Σ=(4112).\mu=\begin{pmatrix}1\\-1\end{pmatrix},\qquad \Sigma=\begin{pmatrix}4&1\\1&2\end{pmatrix}.

The determinant is 4⋅2−1⋅1=74\cdot2-1\cdot1=7, and the inverse is

Σ−1=17(2−1−14).\Sigma^{-1}=\frac17\begin{pmatrix}2&-1\\-1&4\end{pmatrix}.

Writing u=x1−1u=x_1-1 and v=x2+1v=x_2+1, the density becomes

fX(x1,x2)=12π7exp⁡(−2u2−2uv+4v214).f_X(x_1,x_2)=\frac{1}{2\pi\sqrt7}\exp\left(-\frac{2u^2-2uv+4v^2}{14}\right).

For example, at (x1,x2)=(2,1)(x_1,x_2)=(2,1), we have u=1u=1 and v=2v=2. The numerator of the quadratic expression is 2−4+16=142-4+16=14, so the exponent is −1-1. Thus the density there is e−1/(2π7)e^{-1}/(2\pi\sqrt7). This is a density value, not the probability of observing that exact point; for a continuous distribution, probabilities are calculated over regions.

Why the determinant and inverse appear

The determinant measures how the transformation scales volume. A covariance matrix that spreads probability across a larger volume has a larger determinant, so the density’s peak is scaled down by 1/det⁡Σ1/\sqrt{\det\Sigma}. This factor ensures the density integrates to one.

The inverse covariance matrix determines the shape of the exponent’s contours. Directions with large variance contribute less to the quadratic distance, while directions with small variance contribute more. Off-diagonal entries of Σ\Sigma encode relationships between coordinates and produce cross-terms, such as −2uv-2uv in the example.

If Σ\Sigma is diagonal, the coordinates are uncorrelated; for a multivariate normal vector, they are then independent. The multivariate density reduces to the product of the corresponding one-dimensional normal densities.

Common mistakes

  • Using det⁡Σ\det\Sigma instead of its square root. The Jacobian is 1/∣det⁡A∣1/|\det A|, which equals 1/det⁡Σ1/\sqrt{\det\Sigma}.
  • Putting Σ\Sigma in the quadratic form. The correct matrix is Σ−1\Sigma^{-1}; covariance itself describes spread, not the inverse weighting used in the exponent.
  • Leaving out the factor 1/21/2. It is inherited from the standard normal density.
  • Assuming the formula works unchanged for singular covariance. If Σ\Sigma is singular, there is no ordinary density over all of Rd\mathbb{R}^d; the distribution is concentrated on a lower-dimensional subspace and needs a different treatment.

References

  1. Multivariate Statistical Analysis, K. V. Mardia, J. T. Kent, and J. M. Bibby

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.