Course contents 10 / 22

10 / 22 · Several Random Variables

The multivariate Gaussian

Derive Gaussian geometry and conditioning from one covariance matrix. Check affine predictions, distinguish independence from zero covariance, and explain why high-dimensional probability lies away from the density peak.

On this page 7

Two measurements can each fluctuate widely while their difference remains fairly predictable. A covariance matrix records that shared movement. For a jointly Gaussian vector it does more: together with the mean, it determines the entire distribution and lets us update one coordinate after observing another.

The joint-distribution lesson established how marginals, conditioning and independence relate. We now calculate them for a particular family. The main numerical example is a constructed two-coordinate Gaussian model. Its parameters are stipulated; they were not estimated from an empirical dataset.

The density#

A vector is jointly Gaussian when every linear combination of its coordinates is normally distributed, allowing a constant as a zero-variance case. Equivalently, we can construct it from independent standard normal coordinates in a vector ZZ:

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

Its mean is μ\mu and its covariance is Σ=AA⊤\Sigma=AA^\top. The matrix AA may be rectangular or singular; a density over the full output space requires Σ\Sigma to be positive definite. First assume that condition in dimension dd and take an invertible square factor AA.

The inverse transformation is z=A−1(x−μ)z=A^{-1}(x-\mu). For this change of variables, the forward volume factor and the squared length of the inverse image are

∣det⁡A∣=det⁡Σ,∥z∥2=(x−μ)⊤Σ−1(x−μ).\begin{aligned} |\det A|&=\sqrt{\det\Sigma},\\ \|z\|^2&=(x-\mu)^\top\Sigma^{-1}(x-\mu). \end{aligned}

Substituting these into the product of dd standard normal densities gives

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

This construction and the density formula are established in Siegrist’s The Multivariate Normal Distribution, General Distribution. The determinant corrects volume; the quadratic form measures displacement after undoing the covariance transformation.

Use the following model throughout:

μ=(−12),Σ=(5335),det⁡Σ=16,Σ−1=116(5−3−35).\begin{aligned} \mu&=\begin{pmatrix}-1\\2\end{pmatrix},\\ \Sigma&=\begin{pmatrix}5&3\\3&5\end{pmatrix},\\ \det\Sigma&=16,\\ \Sigma^{-1}&=\frac1{16}\begin{pmatrix}5&-3\\-3&5\end{pmatrix}. \end{aligned}

A lower-triangular factor makes the construction explicit:

A=(503/54/5).A=\begin{pmatrix}\sqrt5&0\\3/\sqrt5&4/\sqrt5\end{pmatrix}.

Multiplying AA⊤AA^\top recovers the displayed covariance. Both coordinates have variance 55, and the correlation is 3/53/5. The density at the mean is 1/(8π)≈0.0397891/(8\pi)\approx0.039789. This is a density per unit area; a single point still has probability zero.

Covariance as geometry#

Write the displacement from the mean as δ=x−μ\delta=x-\mu. Its squared Mahalanobis distance is

q(δ)=δ⊤Σ−1δ.q(\delta)=\delta^\top\Sigma^{-1}\delta.

For the chosen matrix,

q(δ)=5δ12−6δ1δ2+5δ2216.q(\delta)=\frac{5\delta_1^2-6\delta_1\delta_2+5\delta_2^2}{16}.

The displacements (1,1)(1,1) and (1,−1)(1,-1) have the same Euclidean length, but their squared Mahalanobis distances are 1/41/4 and 11. Moving both measurements together is more plausible under this covariance than moving them in opposite directions.

The covariance eigenvectors are along (1,1)(1,1) and (1,−1)(1,-1), with eigenvalues 88 and 22. For a positive-definite covariance with orthonormal eigenvector matrix QQ,

Σ=QΛQ⊤,u=Q⊤(x−μ),q=∑i=1dui2λi.\begin{aligned} \Sigma&=Q\Lambda Q^\top,\\ u&=Q^\top(x-\mu),\\ q&=\sum_{i=1}^d\frac{u_i^2}{\lambda_i}. \end{aligned}

Thus a contour q=r2q=r^2 has semiaxis lengths rλir\sqrt{\lambda_i}. The eigenvectors set its directions and the eigenvalues set its squared widths. In our case, the displacements (2,2)(2,2) and (1,−1)(1,-1) both lie on the contour q=1q=1.

Figure

Covariance sets directions and widths

Equal-density Gaussian ellipsesTwo ellipses share a center at minus one, two. Their long axis points along the joint increase of both coordinates. Both axes use the same scale.-327-6-14x₂x₁

Probability inside the contour

  • q ≤ 1: 39.3469%
  • q ≤ 4: 86.4665%

Eigenvalues: 8 and 2. Dashed gray segments show the principal axes of the outer ellipse.

Mean (−1, 2), covariance [[5, 3], [3, 5]]. Blue contour: q = 1; red dashed contour: q = 4. Markers have displacements (2, 2) and (1, −1); both lie on q = 1 despite their different Euclidean distances.

A contour radius is not automatically a one-dimensional coverage rule. In two dimensions, whitening gives q=Z12+Z22q=Z_1^2+Z_2^2. In polar coordinates the angle integrates out, leaving

Pr⁡(q≤r2)=∫0rse−s2/2 ds,=1−e−r2/2.\begin{aligned} \Pr(q\le r^2)&=\int_0^r s e^{-s^2/2}\,ds,\\ &=1-e^{-r^2/2}. \end{aligned}

Consequently, the ellipses at radii 11 and 22 contain approximately 39.3469%39.3469\% and 86.4665%86.4665\% of the probability. The familiar one-coordinate interval percentage does not apply to the radius-one ellipse.

Affine maps#

Let Y=BX+bY=BX+b, where BB and bb are fixed. Substituting the construction gives Y=Bμ+b+BAZY=B\mu+b+BAZ, so the result is again jointly Gaussian, possibly degenerate:

E[Y]=Bμ+b,Cov⁡(Y)=BΣB⊤.\begin{aligned} \mathbb E[Y]&=B\mu+b,\\ \operatorname{Cov}(Y)&=B\Sigma B^\top. \end{aligned}

For a scalar prediction Y=2X1−X2+3Y=2X_1-X_2+3, our model gives

E[Y]=2(−1)−2+3=−1,Var⁡(Y)=4⋅5+5−4⋅3=13.\begin{aligned} \mathbb E[Y]&=2(-1)-2+3=-1,\\ \operatorname{Var}(Y)&=4\cdot5+5-4\cdot3=13. \end{aligned}

Hence Y∼N(−1,13)Y\sim\mathcal N(-1,13), where the second parameter is the variance. The covariance term reduces the variance because the coefficients have opposite signs and the input coordinates tend to move together. Treating those coordinates as independent would instead give 2525 and change the predicted uncertainty.

A rank-deficient map illustrates the density limitation. If ZZ is standard normal and V=(Z,2Z+1)V=(Z,2Z+1), then

E[V]=(01),Cov⁡(V)=(1224).\begin{aligned} \mathbb E[V]&=\begin{pmatrix}0\\1\end{pmatrix},\\ \operatorname{Cov}(V)&=\begin{pmatrix}1&2\\2&4\end{pmatrix}. \end{aligned}

Its determinant is zero and all probability lies on a line. The vector is still jointly Gaussian, but has no density with respect to two-dimensional area. Inserting a pseudoinverse into the full-dimensional density formula does not fix that missing volume.

Marginals and conditionals#

Selecting a coordinate is an affine map. Thus the marginals of our model are X1∼N(−1,5)X_1\sim\mathcal N(-1,5) and X2∼N(2,5)X_2\sim\mathcal N(2,5). A marginal averages over the other coordinate. A conditional instead fixes what was observed and renormalizes the remaining density.

Complete the square in our quadratic form:

q(δ)=δ125+516(δ2−35δ1)2.q(\delta)=\frac{\delta_1^2}{5} +\frac5{16}\left(\delta_2-\frac35\delta_1\right)^2.

When X1=xX_1=x is given, the first term does not depend on the remaining coordinate and cancels in the conditional density ratio. The second term has a Gaussian shape, giving

X2∣X1=x∼N(2+35(x+1),165).X_2\mid X_1=x\sim\mathcal N\left(2+\frac35(x+1),\frac{16}{5}\right).

At the observed value x=3x=3, the conditional mean is 4.44.4 and the variance is 3.23.2. The mean moves upward because the covariance is positive. The variance decreases from 55 because observing one coordinate removes some uncertainty about the other.

Figure

An observation shifts the mean and reduces spread

Marginal and conditional densities of the second coordinateThe solid blue curve is centered at two. The dashed red conditional curve is centered at 4.4, narrower and higher. A finite window of the normal densities is shown.00.10.2-60612Densityx₂

Before the observation: N(2, 5)

After X₁ = 3: N(4.4, 3.2)

The second parameter is the variance. The conditional density is separately normalized; it is not an unnormalized slice through the joint density.

For X₂ the marginal mean is 2 and variance is 5. After observing X₁ = 3, the conditional mean is 4.4 and variance is 3.2. Each complete curve has area one; the y axis shows density.

We obtain this conditional law from fX1,X2(x,y)/fX1(x)f_{X_1,X_2}(x,y)/f_{X_1}(x), whose denominator is positive here. We do not divide by the zero probability of the event X1=xX_1=x. This continuous conditional density also describes the limiting update from an increasingly narrow observation interval. Siegrist’s bivariate conditional theorem states the same general Gaussian dependence on the observed value.

For vectors partitioned into blocks XaX_a and XbX_b, assume the joint covariance is positive definite. Define the residual after subtracting the linear contribution of block bb:

R=Xa−μa−ΣabΣbb−1(Xb−μb).R=X_a-\mu_a-\Sigma_{ab}\Sigma_{bb}^{-1}(X_b-\mu_b).

Multiplying covariances gives Cov⁡(R,Xb)=0\operatorname{Cov}(R,X_b)=0. Since the residual and block bb are jointly Gaussian, the independence result in the next section applies. The residual covariance is the Schur complement:

S=Σaa−ΣabΣbb−1Σba.S=\Sigma_{aa}-\Sigma_{ab}\Sigma_{bb}^{-1}\Sigma_{ba}.

It follows that, at an observed vector xbx_b,

ma∣b=μa+ΣabΣbb−1(xb−μb),Xa∣Xb=xb∼N(ma∣b,S).\begin{aligned} m_{a\mid b}&=\mu_a+\Sigma_{ab}\Sigma_{bb}^{-1}(x_b-\mu_b),\\ X_a\mid X_b=x_b&\sim\mathcal N(m_{a\mid b},S). \end{aligned}

The conditional mean depends on the observation; the conditional covariance does not. That constancy is a property of this Gaussian model, not a general law of conditioning. Numerically, solve linear systems involving Σbb\Sigma_{bb} rather than explicitly forming its inverse.

Gaussian blocks: zero covariance and independence#

If a positive-definite Gaussian covariance is block diagonal, its inverse is block diagonal too and its determinant is the product of the block determinants. Substitution into the joint density separates it into the product of the two marginal densities. Hence Gaussian blocks with zero cross-covariance are independent.

The conclusion also covers singular jointly Gaussian vectors. Their moment-generating function is

MX(t)=E[et⊤X],=exp⁡(t⊤μ+12t⊤Σt).\begin{aligned} M_X(t)&=\mathbb E[e^{t^\top X}],\\ &=\exp\left(t^\top\mu+\frac12t^\top\Sigma t\right). \end{aligned}

With zero cross-covariance, its exponent splits into two block terms, so the moment-generating function factors. Its uniqueness yields independence. The construction, transform formula and block result are given in Siegrist’s multivariate treatment; the residual argument above uses this factorization.

Without joint Gaussianity, zero covariance is insufficient. Let HH take −2,0,2-2,0,2 with probabilities 1/4,1/2,1/41/4,1/2,1/4, and set K=H2K=H^2. Symmetry gives E[H]=0\mathbb E[H]=0 and E[HK]=E[H3]=0\mathbb E[HK]=\mathbb E[H^3]=0, so the covariance is zero. Yet Pr⁡(K=0∣H=0)=1\Pr(K=0\mid H=0)=1, whereas Pr⁡(K=0)=1/2\Pr(K=0)=1/2. One coordinate determines the other. Checking a covariance alone cannot establish independence for an arbitrary joint law.

High dimensions: the shell#

The standard Gaussian density is highest at the origin. That point is nevertheless unrepresentative of the radius of a typical high-dimensional draw. Let ZZ have dd independent standard normal coordinates, and write

R2=∑i=1dZi2.R^2=\sum_{i=1}^d Z_i^2.

For one coordinate the second and fourth moments are 11 and 33. Independence therefore gives

E[R2]=d,Var⁡(R2)=2d.\begin{aligned} \mathbb E[R^2]&=d,\\ \operatorname{Var}(R^2)&=2d. \end{aligned}

Chebyshev’s inequality gives an explicit, conservative concentration bound for ε>0\varepsilon>0:

Pr⁡(∣R2d−1∣≥ε)≤2dε2.\Pr\left(\left|\frac{R^2}{d}-1\right|\ge\varepsilon\right) \le\frac{2}{d\varepsilon^2}.

Take d=512d=512 and ε=1/4\varepsilon=1/4. The upper bound is 1/161/16, so with probability at least 93.75%93.75\% the radius lies between the following limits:

384≈19.595918,640≈25.298221.\begin{aligned} \sqrt{384}&\approx19.595918,\\ \sqrt{640}&\approx25.298221. \end{aligned}

The reference scale is 512≈22.627417\sqrt{512}\approx22.627417. “Thin” means small relative width as dimension grows; it does not mean every draw has the same radius.

Mass moves away from the density peak because a radial band contains more volume at larger radius. Combining that volume with the Gaussian density gives, for r>0r>0,

fR(r)=21−d/2Γ(d/2)rd−1e−r2/2.f_R(r)=\frac{2^{1-d/2}}{\Gamma(d/2)}r^{d-1}e^{-r^2/2}.

Here Γ\Gamma is the gamma function, defined for a>0a>0 by

Γ(a)=∫0∞ta−1e−t dt.\Gamma(a)=\int_0^\infty t^{a-1}e^{-t}\,dt.

This is the chi density; its squared variable has a chi-square distribution with dd degrees of freedom. See Siegrist, Chi-Square and Related Distributions, Moments, Related Distributions and The Chi Distribution. Differentiating the log radial density gives

ddrlog⁡fR(r)=d−1r−r.\frac{d}{dr}\log f_R(r)=\frac{d-1}{r}-r.

For d>1d>1 the mode is therefore d−1\sqrt{d-1}. The radial density includes the amount of volume in a band; the vector density at one location does not.

Figure

Radial mass near its characteristic scale

Densities of relative Gaussian radiusThe solid blue two-dimensional curve is broad. The dashed red sixteen-dimensional and dotted green 128-dimensional curves become narrower around one. These are radius densities, not vector densities.024600.511.52DensityR/√d
  • d = 2
  • d = 16
  • d = 128

The radius density peaks lie away from zero. The peak of the vector density and the peak of the radial density describe different quantities.

Densities of relative radius R/√d for d = 2, 16 and 128. Relative spread decreases as dimension grows. These curves are computed analytically, not from random samples. Tails beyond 2 are not shown.

The plot uses the relative radius R/dR/\sqrt d so different dimensions share a scale. It shows only radii up to twice that scale; tails continue beyond the displayed window. No samples were drawn to produce these curves.

What changed#

A covariance matrix now supports three linked calculations: ellipses show which directions vary together, affine maps propagate that variability, and conditioning removes the part explained by an observation. The same constructed matrix gave a variance of 1313 for a linear prediction and a conditional variance of 3.23.2 for the second coordinate. These are consequences of a joint Gaussian assumption, not conclusions established by the matrix alone.

Limitations#

A mean and covariance determine a Gaussian law only after the family assumption is made. Heavy tails, multiple clusters and nonlinear dependence can share similar moments while giving very different probabilities. Separately normal-looking marginals do not establish joint Gaussianity.

The density and block-inverse formulas require the stated nonsingularity conditions. Nearly singular covariance matrices can make calculations numerically unstable; adding a diagonal regularizer changes the model and should be reported as such. Shell concentration above applies to isotropic standard coordinates, or after whitening a positive-definite Gaussian; it does not directly assert concentration of the ordinary radius for every anisotropic covariance.

What you should remember#

A Gaussian vector can be constructed by an affine map of independent standard normals. Its covariance sets the contour geometry, and the inverse covariance measures displacement in those coordinates. Affine maps and conditioning remain Gaussian; zero cross-covariance gives independence within a jointly Gaussian law. In high dimension, distinguish the density of a vector at a point from probability accumulated over a radial band.

Code#

This deterministic standard-library calculation checks the conditional update, ellipse probabilities and shell bound:

import math

mean = 2 + 3 / 5 * (3 + 1)
variance = 5 - 3 * 3 / 5
print(f"conditional mean={mean:.6f} variance={variance:.6f}")
coverage = [-math.expm1(-r * r / 2) for r in (1, 2)]
print("ellipse probabilities:", " ".join(f"{p:.6f}" for p in coverage))
radii = [math.sqrt(v) for v in (384, 512, 640)]
bound = 2 / (512 * 0.25 ** 2)
print("shell radii:", " ".join(f"{r:.6f}" for r in radii),
      f"; failure_bound={bound:.6f}")
conditional mean=4.400000 variance=3.200000
ellipse probabilities: 0.393469 0.864665
shell radii: 19.595918 22.627417 25.298221 ; failure_bound=0.062500

The repository’s scripts/notes/transformation-gaussian-cases.py additionally checks the covariance factor, the completed square, every plotted ellipse point and numerical normalization of the radial densities. It regenerates original curve coordinates without external data or model dependencies.

Next#

The Gaussian update produced a conditional mean that depends on the observed coordinate. Conditional expectation develops that object for general distributions and connects it to prediction, averaging and residual error.

References#

  • Kyle Siegrist, The Multivariate Normal Distribution, bivariate conditional distributions; multivariate General Distribution and Transformations: Gaussian construction, density, affine maps, marginals and independence.
  • Kyle Siegrist, Chi-Square and Related Distributions, Moments, Related Distributions and The Chi Distribution: squared Gaussian radii and the radial density.
  • Kyle Siegrist, The Normal Distribution, Moments: the standard normal second and fourth moments used in the shell calculation.