The Multivariate Gaussian

W03 · Part 1 — what Σ controls, and why affine maps never leave the family

Uma Satyaranjan · Soma S Dhavala

Invalid Date

Where we are

  • W02 ended at maximum likelihood in one dimension
  • Data is not one-dimensional: an MNIST digit is a point in ℝ784\mathbb{R}^{784}
  • Today: the one family that survives everything we do to it

The claim to keep in view: almost every operation in this course is linear — adding noise, blending signal and noise, projecting, marginalising. The Gaussian is closed under all of them, with parameters you can compute in closed form.

The density

For X∼𝒩(μ,Σ)X \sim \mathcal{N}(\mu, \Sigma) in ℝd\mathbb{R}^d, with Σ\Sigma symmetric positive definite,

p(x)=1(2π)d/2(detΣ)1/2exp(−12(x−μ)⊤Σ−1(x−μ))p(x) = \frac{1}{(2\pi)^{d/2}\,(\det\Sigma)^{1/2}} \exp\!\Big(-\tfrac12 (x-\mu)^{\!\top}\Sigma^{-1}(x-\mu)\Big)

  • The exponent is a quadratic form — so level sets are ellipsoids, always
  • μ\mu moves the centre; Σ\Sigma sets the shape, spread and tilt
  • detΣ\det\Sigma in the constant is the volume factor that makes it integrate to 1

What it costs to go multivariate

A full Σ\Sigma has d(d+1)2\tfrac{d(d+1)}{2} free entries, plus dd for the mean:

d(d+3)2parameters\frac{d(d+3)}{2}\ \text{parameters}

dd parameters
2 5
10 65
784 (MNIST) 308,504

This is the first honest sign of trouble in high dimension — and the reason structure (diagonal, low-rank, factorised) is not laziness but necessity.

Identity covariance: the joint is a product

Set μ=0\mu = 0, Σ=I\Sigma = I. The exponent becomes a sum of squares, and a sum in the exponent is a product outside it:

p(x)=1(2π)d/2e−12∑ixi2=∏i=1d12πe−xi2/2p(x) = \frac{1}{(2\pi)^{d/2}} e^{-\frac12 \sum_i x_i^2} = \prod_{i=1}^{d} \frac{1}{\sqrt{2\pi}} e^{-x_i^2/2}

So 𝒩(0,I)\mathcal{N}(0,I) is exactly dd independent standard normals.

Diagonal Σ\Sigma ⇒\Rightarrow independent coordinates — but only because it is Gaussian. In general, uncorrelated does not imply independent.

The results, in one table

X∼𝒩(μ,Σ)X \sim \mathcal{N}(\mu,\Sigma) throughout.

Result Statement
Affine map AX+b∼𝒩(Aμ+b,AΣA⊤)AX + b \sim \mathcal{N}(A\mu + b,\ A\Sigma A^{\!\top})
Projection a⊤X∼𝒩(a⊤μ,a⊤Σa)a^{\!\top}X \sim \mathcal{N}(a^{\!\top}\mu,\ a^{\!\top}\Sigma a)
Marginal XS∼𝒩(μS,ΣSS)X_S \sim \mathcal{N}(\mu_S, \Sigma_{SS}) — delete the other rows and columns
Independent sum X+Y∼𝒩(μ+ν,Σ+T)X + Y \sim \mathcal{N}(\mu+\nu,\ \Sigma + T)
Whitening Σ=LL⊤⇒L−1(X−μ)∼𝒩(0,I)\Sigma = LL^{\!\top} \Rightarrow L^{-1}(X-\mu) \sim \mathcal{N}(0,I)
MGF 𝔼[et⊤X]=exp(t⊤μ+12t⊤Σt)\mathbb{E}\big[e^{t^{\!\top}X}\big] = \exp\!\big(t^{\!\top}\mu + \tfrac12 t^{\!\top}\Sigma t\big)

The first line is the engine. Everything above it is a special case — and we prove it now.

The claim

Theorem. Let X∼𝒩(μ,Σ)X \sim \mathcal{N}(\mu,\Sigma) in ℝd\mathbb{R}^d, and let A∈ℝm×dA \in \mathbb{R}^{m\times d}, b∈ℝmb \in \mathbb{R}^m. Then

Y=AX+b∼𝒩(Aμ+b,AΣA⊤).Y = AX + b \;\sim\; \mathcal{N}\big(A\mu + b,\ A\Sigma A^{\!\top}\big).

Two separate things to establish, and it is worth not conflating them:

  1. the mean and covariance are what the formula says — true for any distribution with two moments, no normality involved;
  2. the result is still Gaussian — this is the part with content.

Step 1 — mean and covariance need no normality

Linearity of expectation:

𝔼[Y]=A𝔼[X]+b=Aμ+b\mathbb{E}[Y] = A\,\mathbb{E}[X] + b = A\mu + b

And straight from the definition of covariance, using Y−𝔼[Y]=A(X−μ)Y - \mathbb{E}[Y] = A(X - \mu):

Cov(Y)=𝔼[(Y−𝔼Y)(Y−𝔼Y)⊤]=𝔼[A(X−μ)(X−μ)⊤A⊤]\operatorname{Cov}(Y) = \mathbb{E}\big[(Y-\mathbb{E}Y)(Y-\mathbb{E}Y)^{\!\top}\big] = \mathbb{E}\big[A(X-\mu)(X-\mu)^{\!\top}A^{\!\top}\big]

AA is constant, so it comes outside the expectation:

Cov(Y)=A𝔼[(X−μ)(X−μ)⊤]A⊤=AΣA⊤\operatorname{Cov}(Y) = A\,\mathbb{E}\big[(X-\mu)(X-\mu)^{\!\top}\big]\,A^{\!\top} = A\Sigma A^{\!\top}

Note bb has vanished — shifting cannot change a covariance.

Detour: the moment generating function

For a random vector XX in ℝd\mathbb{R}^d,

MX(t)=𝔼[et⊤X],t∈ℝdM_X(t) \;=\; \mathbb{E}\big[e^{t^{\!\top}X}\big], \qquad t \in \mathbb{R}^d

Why “moment generating”. Expand etX=∑ktkXk/k!e^{tX} = \sum_k t^k X^k/k! and differentiate at the origin — each derivative pulls down one moment:

∇MX(0)=μ,∇2MX(0)=𝔼[XX⊤]=Σ+μμ⊤\nabla M_X(0) = \mu, \qquad \nabla^2 M_X(0) = \mathbb{E}\big[XX^{\!\top}\big] = \Sigma + \mu\mu^{\!\top}

One function of tt, carrying every moment of XX.

Why the MGF is enough

Uniqueness theorem. If MX(t)=MY(t)M_X(t) = M_Y(t) for all tt in some open neighbourhood of the origin, then XX and YY have the same distribution.

The MGF does not merely summarise a law — it determines it. That is what licenses the whole strategy: compute an MGF, recognise its shape, conclude.

The honest caveat. Not every distribution has an MGF — 𝔼[etX]\mathbb{E}[e^{tX}] is infinite for a Cauchy at every t≠0t \ne 0. The repair is the characteristic function φX(t)=𝔼[eit⊤X]\varphi_X(t) = \mathbb{E}[e^{i t^{\!\top}X}], which always exists (|eiθ|=1|e^{i\theta}|=1) and obeys the same theorem. For the Gaussian the MGF exists everywhere, so we use the simpler object.

The MGF of a Gaussian — scalar case

X∼𝒩(μ,σ2)X \sim \mathcal{N}(\mu,\sigma^2). Everything lives in the exponent:

MX(t)=∫etx12πσ2e−(x−μ)2/2σ2dxM_X(t) = \int e^{tx}\,\frac{1}{\sqrt{2\pi\sigma^2}}\,e^{-(x-\mu)^2/2\sigma^2}\,dx

Complete the square in the exponent:

tx−(x−μ)22σ2=μt+12σ2t2⏟free of x−(x−μ−σ2t)22σ2tx - \frac{(x-\mu)^2}{2\sigma^2} = \underbrace{\mu t + \tfrac12\sigma^2 t^2}_{\text{free of } x} \;-\; \frac{(x - \mu - \sigma^2 t)^2}{2\sigma^2}

The first part leaves the integral; the rest is a Gaussian density with mean μ+σ2t\mu + \sigma^2 t, which integrates to 11:

MX(t)=exp(μt+12σ2t2)\boxed{\;M_X(t) = \exp\!\big(\mu t + \tfrac12 \sigma^2 t^2\big)\;}

…and in dd dimensions

For Z∼𝒩(0,I)Z \sim \mathcal{N}(0,I) the coordinates are independent, so the expectation factorises:

MZ(t)=∏i𝔼[etiZi]=∏ieti2/2=e12t⊤tM_Z(t) = \prod_i \mathbb{E}\big[e^{t_i Z_i}\big] = \prod_i e^{t_i^2/2} = e^{\frac12 t^{\!\top}t}

For X∼𝒩(μ,Σ)X \sim \mathcal{N}(\mu,\Sigma), substitute x=μ+Lux = \mu + Lu with Σ=LL⊤\Sigma = LL^{\!\top}. The Jacobian detL\det L cancels the (detΣ)1/2(\det\Sigma)^{1/2} in the constant, leaving the standard case at L⊤tL^{\!\top}t:

MX(t)=exp(t⊤μ+12t⊤Σt)\boxed{\;M_X(t) = \exp\!\Big(t^{\!\top}\mu + \tfrac12\, t^{\!\top}\Sigma\, t\Big)\;}

Remember the shape: the exponent is a quadratic in tt. Everything below follows from that alone. (This was a change of variables in an integral, not the affine theorem — so no circularity.)

Step 2 — compute the MGF of Y=AX+bY = AX + b

MY(t)=𝔼[et⊤Y]=𝔼[et⊤(AX+b)]M_Y(t) = \mathbb{E}\big[e^{t^{\!\top}Y}\big] = \mathbb{E}\big[e^{t^{\!\top}(AX+b)}\big]

definition of the MGF, then substitute Y=AX+bY = AX+b

=et⊤b𝔼[et⊤AX]= e^{t^{\!\top}b}\;\mathbb{E}\big[e^{t^{\!\top}AX}\big]

bb is constant, so et⊤be^{t^{\!\top}b} leaves the expectation

=et⊤b𝔼[e(A⊤t)⊤X]= e^{t^{\!\top}b}\;\mathbb{E}\big[e^{(A^{\!\top}t)^{\!\top}X}\big]

since t⊤A=(A⊤t)⊤t^{\!\top}A = (A^{\!\top}t)^{\!\top}

That third line is the move. The matrix has been pushed off the random vector and onto the argument. The expectation is now just MXM_X evaluated at the point A⊤tA^{\!\top}t — and we know MXM_X.

Step 2 — recognise what comes out

Apply the Gaussian MGF at A⊤tA^{\!\top}t:

MY(t)=et⊤bexp((A⊤t)⊤μ+12(A⊤t)⊤Σ(A⊤t))M_Y(t) = e^{t^{\!\top}b}\exp\!\Big((A^{\!\top}t)^{\!\top}\mu + \tfrac12 (A^{\!\top}t)^{\!\top}\Sigma (A^{\!\top}t)\Big)

=exp(t⊤b+t⊤Aμ+12t⊤AΣA⊤t)= \exp\!\Big(t^{\!\top}b + t^{\!\top}\!A\mu + \tfrac12\, t^{\!\top}\!A\Sigma A^{\!\top}t\Big)

transpose each piece

=exp(t⊤(Aμ+b)+12t⊤(AΣA⊤)t)= \exp\!\Big(t^{\!\top}\big(A\mu + b\big) + \tfrac12\, t^{\!\top}\big(A\Sigma A^{\!\top}\big)t\Big)

collect the linear terms

Now read it. The result has the form exp(t⊤m+12t⊤St)\exp\big(t^{\!\top}m + \tfrac12 t^{\!\top}S t\big) — linear plus quadratic, exactly a Gaussian MGF, with m=Aμ+bm = A\mu+b and S=AΣA⊤S = A\Sigma A^{\!\top}. By uniqueness, YY is that Gaussian. ◼\blacksquare

What actually did the work

  • The Gaussian MGF has a quadratic exponent, and A⊤tA^{\!\top}t substituted into a quadratic is still a quadratic. That is the whole mechanism
  • Push almost any other family through a linear map and the functional form changes — you leave the family and lose the closed form
  • Equivalently, by change of variables: y=Ax+by = Ax+b has x=A−1(y−b)x = A^{-1}(y-b) and a constant Jacobian |detA|−1|\det A|^{-1}, so a quadratic exponent stays quadratic. The MGF route is shorter and does not need AA invertible

This closure is the entire reason diffusion models are analytically tractable: p(xt∣x0)p(x_t \mid x_0) has a closed form at every tt because every step is affine.

Read it in both directions

Factor Σ=LL⊤\Sigma = LL^{\!\top} (Cholesky, or Σ1/2\Sigma^{1/2}).

Forward — sampling. Take z∼𝒩(0,I)z \sim \mathcal{N}(0,I) and set A=LA = L, b=μb = \mu:

μ+Lz∼𝒩(μ,LIL⊤)=𝒩(μ,Σ)\mu + Lz \;\sim\; \mathcal{N}\big(\mu,\ L I L^{\!\top}\big) = \mathcal{N}(\mu,\Sigma)

Backward — whitening. Take A=L−1A = L^{-1}, b=−L−1μb = -L^{-1}\mu:

L−1(X−μ)∼𝒩(0,L−1ΣL−⊤)=𝒩(0,I)L^{-1}(X - \mu) \;\sim\; \mathcal{N}\big(0,\ L^{-1}\Sigma L^{-\top}\big) = \mathcal{N}(0,I)

One theorem, applied twice. This is why you may always assume 𝒩(0,I)\mathcal{N}(0,I) without loss of generality — and how a sampler turns standard noise into any Gaussian you like.

The degenerate case

If rank(A)<d\operatorname{rank}(A) < d, then AΣA⊤A\Sigma A^{\!\top} is singular: det=0\det = 0, and the density formula breaks down.

A=(1224)⇒det(AΣA⊤)=0A = \begin{pmatrix} 1 & 2 \\ 2 & 4\end{pmatrix} \quad\Longrightarrow\quad \det\big(A\Sigma A^{\!\top}\big) = 0

  • The law is still Gaussian, but it lives on a lower-dimensional subspace
  • It has no density with respect to Lebesgue measure on ℝm\mathbb{R}^m
  • The theorem survives; only the density formula fails

This is the same singularity as the manifold hypothesis, reached deliberately rather than by accident. Real image data is believed to sit on exactly such a thin set.

See it move

Act II drags AA and watches the ellipse follow AΣA⊤A\Sigma A^{\!\top}; the singular preset collapses the cloud onto a line.

Where this lands

Today Where it returns
AX+bAX+b closure p(xt∣x0)p(x_t \mid x_0) in closed form at every noise level
μ+Lz\mu + Lz how every Gaussian sample is drawn, from standard noise
Whitening why 𝒩(0,I)\mathcal{N}(0,I) costs no generality
Independent sum variances add — the t\sqrt{t} envelope of the forward process
Singular AΣA⊤A\Sigma A^{\!\top} data on a manifold; why densities are the wrong object there

Affine maps move a Gaussian’s mean and reshape its covariance — but never take it out of the family.

Reference: 05 · The Multivariate Gaussian. Tutorial: Inequalities Worth Knowing. Demo: The Gaussian Lab.