Multivariate Gaussian
The bell curve grown into many dimensions: a center plus a covariance matrix that stretches the cloud into a tilted ellipse.
Why Does This Exist?
Noise in ML is rarely one-dimensional. Sensor errors, embedding jitter, and weight priors all vary along many axes at once, and the variation leans: errors in predict errors in . A pile of independent one-dimensional bells cannot express that lean, so every model that reasons about joint uncertainty, from Kalman filters to Gaussian processes to variational posteriors, reaches for the distribution that can.
The multivariate Gaussian is that distribution, and it earns its ubiquity structurally. It is fully described by a mean vector and a covariance matrix. Its marginals and conditionals are Gaussian again, in closed form. Linear maps keep it Gaussian. And the central limit theorem makes it the default shape of averaged noise. The single-variable bell is probability distributions; the averaging behind covariance is expectation, variance and covariance.
The one idea you need first
A Gaussian in one dimension has a center and a spread , with density falling exponentially in squared distance from center. In dimensions the center becomes a vector and the spread becomes a covariance matrix , while squared distance becomes the Mahalanobis form . Everything below is that substitution, followed faithfully.
Think of It Like This
A spotlight on a tilted stage
A spotlight throws an elliptical pool of light: brightest at center, fading outward, stretched along one direction. Tilt the lamp and the ellipse rotates; widen the beam and it grows. The brightness at any floor tile is the density there.
The mean vector aims the lamp and the covariance matrix shapes the pool. Variances set the beam width along each axis, covariances tilt it, and the determinant sets the total light: a stretched pool spreads the same unit of probability thinner. Contours of equal brightness are ellipses, which is why Gaussian reasoning always draws ellipses, and why the diagram's rings are the whole story in miniature.
The analogy stops at the tails. Light has an edge, but Gaussian brightness never reaches zero, only fades. Real data with hard cutoffs needs truncated or bounded distributions instead.
How It Actually Works
The density in dimensions:
In plain words: center the point, measure its squared length in the covariance's own units (Mahalanobis distance), decay exponentially, and normalize by the matrix's determinant. Three structural facts run practice:
- Marginals stay Gaussian. Drop coordinates and the rest is Gaussian with the corresponding sub-vector and sub-matrix. Reading one sensor of a Gaussian array never leaves the family.
- Conditionals stay Gaussian. Fix some coordinates and the rest is Gaussian with a shifted mean and a shrunk covariance. Observing can only reduce uncertainty, never reshape its type.
- Eigenvectors draw the ellipse. The covariance's eigenvectors point along the ellipse axes with lengths , which is why eigenvalues and eigenvectors are the natural sequel.
In plain words again: the mean says where, the eigenvectors say which way it stretches, the eigenvalues say how far, and every slice or projection keeps the same bell shape.
Worked example
Take with : standard deviations and with correlation .
Determinant: . Center density: . Now the point , one raw standard deviation along . Its Mahalanobis distance is not : with , the quadratic form is , so the distance is . Correlation pushes the point effectively farther, because the cloud's tilt makes pure- excursions unusual. Its density is , less than half the center's.
Code
The 2-by-2 density from scratch, no libraries beyond the standard one, reproducing the hand numbers.
import math
cov = [[4.0, 1.2], [1.2, 1.0]]det = cov[0][0] * cov[1][1] - cov[0][1] ** 2norm = 1.0 / (2 * math.pi * math.sqrt(det))inv = [[cov[1][1] / det, -cov[0][1] / det], [-cov[1][0] / det, cov[0][0] / det]]
def density(x: float, y: float) -> float: quad = inv[0][0] * x**2 + 2 * inv[0][1] * x * y + inv[1][1] * y**2 return norm * math.exp(-0.5 * quad)
print(round(det, 4)) # -> 2.56print(round(density(0.0, 0.0), 4)) # -> 0.0995print(round(density(2.0, 0.0), 4)) # -> 0.0455The prints give 2.56, 0.0995, and 0.0455, matching the hand derivation exactly. The quad line is the Mahalanobis distance squared, the only part that changes with dimension.
Watch Out For
Measuring Gaussian distance in raw Euclidean units
One raw sigma along a correlated axis is not one sigma of surprise, as the worked 1.25 shows. Nearest-neighbor searches, anomaly thresholds, and confidence ellipses drawn in Euclidean distance misrank every tilted point. Whiten with the covariance first, or use Mahalanobis distance throughout, or the ellipse's tilt silently reorders your answers.
Assuming Gaussianity because only two moments were checked
Matching a mean and covariance proves nothing about shape: heavy-tailed, multimodal, and skewed distributions wear identical first-two-moment masks. Gaussian closures, Kalman updates, and analytic posteriors all break when the true noise is not bell-shaped. Check tails and slices before trusting the family's conveniences.
The Quick Version
- The multivariate Gaussian is a mean vector plus a covariance matrix, and nothing else.
- Its density decays exponentially in Mahalanobis distance, with the determinant normalizing.
- Marginals and conditionals stay Gaussian in closed form; observing only shrinks uncertainty.
- Eigenvectors aim the ellipse axes and eigenvalues set their lengths.
- Correlation 0.6 makes one raw x-sigma worth 1.25 Mahalanobis, with density 0.0455 against 0.0995.