The Multivariate Normal Distribution
Mean vectors and covariance matrices, contours of constant density, marginals and conditionals.
Assumes you know
The Multivariate Normal Distribution
Intuition first
The multivariate normal extends the bell curve to several dimensions at once. Instead of a mean and a variance, it has a mean vector saying where the centre is and a covariance matrix saying how the dimensions vary and how they vary together.
Geometrically, the contours of constant density are ellipses (or ellipsoids). The covariance matrix determines their shape and orientation: equal variances and zero covariance give circles, unequal variances give axis-aligned ellipses, and non-zero covariance tilts them. Reading a covariance matrix as an ellipse is the single most useful mental image in multivariate statistics.
It matters out of proportion to its apparent narrowness because it is the only multivariate distribution that is genuinely tractable. Linear combinations stay normal, marginals are normal, conditionals are normal and their means are linear in the conditioning variables — which is exactly where linear regression comes from. PCA, LDA, Gaussian mixtures, Kalman filters and Gaussian processes all rest on this one distribution.
Definition
| Symbol | Meaning | Read aloud |
|---|---|---|
| μ | Mean vector, d components | mu |
| Σ | Covariance matrix, d × d, symmetric positive definite | sigma |
| |Σ| | Determinant — the generalised variance | det sigma |
| Σ⁻¹ | Precision matrix | sigma inverse |
| d² | Squared Mahalanobis distance | d squared |
Reading the covariance matrix
For two dimensions:
The eigenvectors of give the ellipse axes and the eigenvalues their squared lengths. That is precisely what PCA computes: the principal components are the eigenvectors of the covariance matrix, ordered by how much variance each direction carries.
The three properties that make it tractable
Linear combinations stay normal. For any matrix and vector :
Marginals are normal. Just pick out the relevant entries of and the corresponding block of — no integration required.
Conditionals are normal, with linear means. Partition :
What the conditional formula is telling youAdvanced
Two features deserve attention.
The conditional mean is linear in . The coefficient matrix is exactly the matrix of regression coefficients. In the bivariate case it reduces to
and is the familiar least-squares slope. So linear regression is the conditional mean of a multivariate normal. That is why linear regression is the right model when the joint distribution is normal, and why it is only an approximation otherwise.
The conditional variance does not depend on . The term — the Schur complement — is a constant. This is homoscedasticity, assumed by ordinary least squares, and here it is a consequence of joint normality rather than an extra assumption.
The conditional variance is also never larger than the marginal variance: conditioning on information can only reduce uncertainty, and the reduction is exactly of it in the bivariate case, since
That is the residual fraction of variance, so is the fraction explained — which is .
Solved problem 1 · Bivariate normal: marginals, conditionals, and a probability
Heights (, cm) and weights (, kg) are bivariate normal with
(a) Find the correlation. (b) Find the distribution of weight given height 185 cm. (c) Find .
Step 1 — part (a): extract the correlation
Step 2 — part (b): the conditional mean
Using the bivariate form with as the target and as the conditioner:
The slope is
At :
Step 3 — the conditional variance
So
Step 4 — part (c): standardise within the conditional
Step 5 — compare with the unconditional answer
Without knowing the height:
Knowing the person is 10 cm above average height more than doubles the probability that they exceed 85 kg, from 20% to 47%. Conditioning also cut the standard deviation from 12 to 9.37, a reduction of exactly .
Answer
(a) ; (b) with SD ; (c) , against an unconditional .
Independence and zero correlation coincide here
For general random variables, zero correlation does not imply independence. For jointly normal variables it does:
Degenerate cases
If is singular the density does not exist, because and are undefined. This happens when one variable is an exact linear combination of others — the distribution then lives on a lower-dimensional subspace.
import numpy as np
from scipy import stats
mu = np.array([175.0, 75.0])
Sigma = np.array([[64.0, 60.0],
[60.0, 144.0]])
s1, s2 = np.sqrt(Sigma[0,0]), np.sqrt(Sigma[1,1])
rho = Sigma[0,1] / (s1 * s2)
print(f"rho {rho:.4f} sigma1 {s1:.1f} sigma2 {s2:.1f}")
# Conditional distribution of weight given height = 185.
x1 = 185.0
slope = Sigma[1,0] / Sigma[0,0] # = rho * s2/s1
cond_mu = mu[1] + slope * (x1 - mu[0])
cond_var = Sigma[1,1] - Sigma[1,0]**2 / Sigma[0,0]
print(f"\nslope {slope:.4f} kg/cm cond mean {cond_mu:.4f} cond var {cond_var:.4f}")
print(f"P(W > 85 | H = 185) {stats.norm.sf(85, cond_mu, np.sqrt(cond_var)):.4f}")
print(f"P(W > 85) {stats.norm.sf(85, mu[1], s2):.4f}")
# Eigenstructure: the ellipse axes are the principal components.
vals, vecs = np.linalg.eigh(Sigma)
print(f"\neigenvalues {vals.round(3)} (axis lengths squared)")
print(f"variance explained by PC1: {vals[-1]/vals.sum():.1%}")
# Verify by simulation, including the conditional slice.
rng = np.random.default_rng(0)
X = rng.multivariate_normal(mu, Sigma, 2_000_000)
band = np.abs(X[:,0] - 185) < 0.25
print(f"\nempirical cond mean {X[band,1].mean():.4f} sd {X[band,1].std():.4f}")
print(f"theory {cond_mu:.4f} {np.sqrt(cond_var):.4f}")
# Mahalanobis distance is chi-squared with d degrees of freedom.
diff = X - mu
d2 = np.einsum('ij,jk,ik->i', diff, np.linalg.inv(Sigma), diff)
print(f"\nMahalanobis²: mean {d2.mean():.4f} (theory 2) "
f"95th pct {np.percentile(d2, 95):.4f} (chi2(2) {stats.chi2.ppf(0.95, 2):.4f})")That final check is worth knowing: , which is how you set a principled multivariate outlier threshold rather than eyeballing one per dimension.
Exercise 1
. Find the distribution of .
Show solutionHide solution
Write with , a matrix. Linear combinations of a multivariate normal are normal, so is univariate normal.
Mean:
Variance:
First multiply :
Then:
So .
Check against the scalar formula:
Note the positive covariance reduced the variance of the difference — the two variables move together, so subtracting cancels part of the shared fluctuation.
Exercise 2
Explain why Mahalanobis distance is preferred to Euclidean distance for detecting multivariate outliers.
Show solutionHide solution
Euclidean distance treats all directions as equivalent and ignores both scale and correlation. Mahalanobis distance,
corrects for both.
Scale. With height in centimetres (SD 8) and weight in kilograms (SD 12), a Euclidean distance adds centimetres to kilograms — meaningless, and dominated by whichever variable happens to have larger units. Change height to metres and the answer changes completely. Mahalanobis divides each direction by its standard deviation, making it unit-free.
Correlation. With , a person 10 cm taller and 9 kg heavier than average is entirely typical, since that is precisely the pattern the correlation predicts. A person 10 cm taller and 9 kg lighter is unusual. Both points are the same Euclidean distance from the mean. Mahalanobis distance, via , knows the ellipse is tilted and gives the second point a much larger value.
It has a calibrated threshold. For multivariate normal data, , so the 95th percentile of is a principled cut-off. Euclidean distance has no such reference distribution, leaving the threshold arbitrary.
The practical caveat: must be estimated, and the sample covariance is itself distorted by outliers — the very things being detected. Robust estimators such as the minimum covariance determinant exist for this reason.
That completes the distributions in this module. Next: Statistics and Inference, which uses all of this to reason from samples back to populations.