MIT 18.650 — Lecture 6

The Multivariate Gaussian

§ Multivariate PDFs

Random vectors XRkX \in \mathbb{R}^{k} can have PDFs f(x)f(x) too, where Pr(XR)=Rf(x)dx\Pr(X \in R) = \int_R f(x) \, \mathrm{d}x for any (measurable) region RRkR \subseteq \mathbb{R}^k.

The PDF f:RkRf: \mathbb{R}^k \to \mathbb{R} of a random vector X=(X1,,Xk)X = (X_1, \dots, X_k) is called the joint density of (X1,,Xk)(X_1, \dots, X_k).

Example. If {Xi}i=1k\{X_i\}_{i = 1}^k are independent, and the PDF (or marginal density) of XiX_i is given by fi(x)f_i(x), then their joint density is given by f(x1,,xk)=i=1kfi(xi)f(x_1, \dots, x_k) = \prod_{i = 1}^k f_i(x_i).

Definition (Conditional PDF). Given X1,,XkX_1, \dots, X_k with joint density f(x1,,xk)f(x_1, \dots, x_k), the conditional density of XkX_k given the values {X1=x1,,Xk1=xk1}\{X_1 = x_1, \dots, X_{k - 1} = x_{k - 1}\} is:

f(xk{X1=x1,,Xk1=xk1})=f(x1,,xk)Rf(x1,,xk1,t)dt.f(x_k \mid \{X_1 = x_1, \dots, X_{k - 1} = x_{k - 1}\}) = \frac{f(x_1, \dots, x_k)}{\int_{\mathbb{R}} f(x_1, \dots, x_{k - 1}, t) \, \mathrm{d}t}.

Note that the conditional PDF ff can be viewed as either:

§ Multivariate Gaussian

18.650 states the Multivariate Gaussian PDF without proof. For completeness, we give a derivation here.

Theorem. (Multivariate Gaussian) The kk-dimensional Gaussian random vector XNk(μ,Σ)X \sim \mathcal{N}_k(\mu, \Sigma) satisfies μ=E[X]\mu = \mathbb{E}[X], Σ=V[X]\Sigma = \mathbb{V}[X], and has multivariate PDF given by:

f(x)=1(2π)kdet(Σ)exp(12(xμ)Σ1(xμ)).f(x) = \frac{1}{\sqrt{(2\pi)^k \det(\Sigma)}} \exp\left(-\frac{1}{2}(x - \mu)^{\top}\Sigma^{-1}(x - \mu)\right).

Proof: Start with the case of Σ=Ik\Sigma = I_k and μ=0\mu = 0; that is, consider ZNk(0,Ik)Z \sim \mathcal{N}_k(0, I_k).

Since Σ=Ik\Sigma = I_k, the {Zi}i=1k\{Z_i\}_{i = 1}^k are independent, so the multivariate PDF is just the product of all the single-variable PDFs:

fZ(z)=i=1k12πezi2/2=1(2π)kexp(12zz).f_Z(z) = \prod_{i = 1}^k \frac{1}{\sqrt{2\pi}} e^{-z_i^2/2} = \frac{1}{\sqrt{(2\pi)^k}} \exp\left(-\frac{1}{2}z^{\top}z\right).

The question now is: for what ARk×kA \in \mathbb{R}^{k \times k} and bRkb \in \mathbb{R}^k does X:=AZ+bX := AZ + b satisfy E[X]=μ\mathbb{E}[X] = \mu and V[X]=Σ\mathbb{V}[X] = \Sigma? Well,

μ=E[AZ+b]=AE[Z]+b=b.      Σ=V[AZ+b]=AV[Z]A=AA.\mu = \mathbb{E}[AZ + b] = A\mathbb{E}[Z] + b = b. ~~~ \parallel ~~~ \Sigma = \mathbb{V}[AZ + b] = A\mathbb{V}[Z]A^{\top} = AA^{\top}.

Thus, we seek X=Σ1/2Z+μX = \Sigma^{1/2}Z + \mu, where Σ1/2\Sigma^{1/2} is the unique symmetric, positive definite matrix such that Σ=Σ1/2Σ1/2\Sigma = \Sigma^{1/2}\Sigma^{1/2}.

Why does Σ1/2\Sigma^{1/2} always exist? Well, by the Spectral Theorem, Σ=QΛQ\Sigma = Q \Lambda Q^{\top}, where Λ=diag(λ1,,λk)\Lambda = \mathrm{diag}(\lambda_1, \dots, \lambda_k) and QOk(R)Q \in O_k(\mathbb{R}). But Σ\Sigma is positive definite, so the λi\lambda_i are all positive, meaning Σ1/2:=QΛ1/2Q\Sigma^{1/2} := Q \Lambda^{1/2} Q^{\top} works.

Returning to the PDF fZ(z)f_Z(z), we therefore must substitute z=Σ1/2(xμ)z = \Sigma^{-1/2}(x - \mu). Careful, though—fZ(z)f_Z(z) is a density, and the affine map T(z)=Σ1/2z+μT(z) = \Sigma^{1/2}z + \mu will stretch space by a factor of det(Σ1/2)=det(Σ)1/2\det(\Sigma^{1/2}) = \det(\Sigma)^{1/2}. Thus, the final PDF is:

fX(x)=fZ(z)1det(Σ)1/2=1(2π)kexp(12(Σ1/2(xμ))(Σ1/2(xμ)))1det(Σ)1/2.f_X(x) = f_Z(z) \cdot \frac{1}{\det(\Sigma)^{1/2}} = \frac{1}{\sqrt{(2\pi)^k}} \exp\left(-\frac{1}{2}(\Sigma^{-1/2}(x - \mu))^{\top} (\Sigma^{-1/2}(x - \mu))\right) \cdot \frac{1}{\det(\Sigma)^{1/2}}.

And the above simplifies to the multivariate PDF promised at the beginning.   \blacksquare

Note that all covariance matrices are positive semidefinite, so the above theorem only makes sense when Σ\Sigma is symmetric and positive semidefinite. More strongly, we better have Σ\Sigma be positive definite, or else Σ\Sigma would give a degenerate Gaussian with no PDF, as Σ1\Sigma^{-1} would make no sense.

§ Multivariate Gaussian Properties and Theorems

It helps to know a few useful properties of Nk(μ,Σ)\mathcal{N}_k(\mu, \Sigma).

Theorem. (Multivariate Gaussian Properties) Say XNk(μ,Σ)X \sim \mathcal{N}_k(\mu, \Sigma). Then:

Proof: For the first bullet, just note that AX+bA^{\top}X + b is clearly also a multivariate Gaussian, and so it suffices to compute E[AX+b]\mathbb{E}[A^{\top}X + b] and V[AX+b]\mathbb{V}[A^{\top}X + b], which is not hard.   \blacksquare

And of course, multivariate CLT holds too.

Theorem. (Multivariate CLT) Given (i.i.d.) random vectors X1,,XnRkX_1, \dots, X_n \in \mathbb{R}^k, with E[Xi]=μ\mathbb{E}[X_i] = \mu and V[Xi]=Σ\mathbb{V}[X_i] = \Sigma, we have:

n(Xˉnμ)Nk(0,Σ).\sqrt{n}(\bar{X}_n - \mu) \rightsquigarrow \mathcal{N}_k(0, \Sigma).

And so does the multivariate delta method.

Theorem. (Multivariate Delta Method) Given (i.i.d.) random vectors X1,,XnRkX_1, \dots, X_n \in \mathbb{R}^k with E[Xi]=μ\mathbb{E}[X_i] = \mu and V[Xi]=Σ\mathbb{V}[X_i] = \Sigma, along with a differentiable g:RkRg: \mathbb{R}^k \to \mathbb{R} satisfying g(μ)0\nabla g(\mu) \neq 0, we have:

n(g(Xˉn)g(μ))N(0,g(μ)Σg(μ)).\sqrt{n}\left(g(\bar{X}_n) - g(\mu)\right) \rightsquigarrow \mathcal{N}\left(0, \nabla g(\mu)^{\top} \Sigma \nabla g(\mu)\right).

Note, in this case, that the RHS is a single-variable Gaussian, and that g(μ)\nabla g(\mu) is a column vector, not a matrix.

Example. Consider i.i.d. random vectors X1,,XnN((2,,2),Ik)X_1, \dots, X_n \sim \mathcal{N}((2, \dots, 2), I_k), and define g:RkRg: \mathbb{R}^k \to \mathbb{R} via g(x1,,xk)=x1xkg(x_1, \dots, x_k) = x_1\dots x_k. Determine the limiting distribution of g(Xˉn)g(\bar{X}_n).

Solution: Just note that g(μ)=2kg(\mu) = 2^k and g(μ)=(2k1,,2k1)\nabla g(\mu) = (2^{k - 1}, \dots, 2^{k - 1}), so the Delta Method yields:

n(g(Xˉn)2k)N(0,k22k2).\sqrt{n}\left(g(\bar{X}_n) - 2^k\right) \rightsquigarrow \mathcal{N}(0, k \cdot 2^{2k - 2}).

And so g(Xˉn)N(2k,1n(k22k2))g(\bar{X}_n) \approx \mathcal{N}\left(2^k, \frac{1}{n}(k \cdot 2^{2k - 2}) \right) in the limit nn \to \infty.

§ Computational Examples

Example. Consider a random vector distributed as (XY)N((32),(4116))\begin{pmatrix} X \\ Y \end{pmatrix} \sim \mathcal{N}\left(\begin{pmatrix} 3 \\ 2 \end{pmatrix}, \begin{pmatrix} 4 & 1 \\ 1 & 6 \end{pmatrix}\right). Compute V[X+3Y]\mathbb{V}[X + 3Y].

Solution: Computing V[X+3Y]\mathbb{V}[X + 3Y] doesn't even depend on our random vector being jointly Gaussian; just note:

V[X+3Y]=V[(13)(XY)]=(13)(4116)(13)=64.\mathbb{V}[X + 3Y] = \mathbb{V}\left[\begin{pmatrix} 1 \\ 3 \end{pmatrix}^{\top} \begin{pmatrix} X \\ Y \end{pmatrix}\right] = \begin{pmatrix} 1 \\ 3 \end{pmatrix}^{\top} \begin{pmatrix} 4 & 1 \\ 1 & 6 \end{pmatrix} \begin{pmatrix} 1 \\ 3 \end{pmatrix} = 64.

Here's an alternative solution.

V[X+3Y]=V[X]+V[3Y]+2Cov(X,3Y)=V[X]+9V[Y]+6Cov(X,Y)=4+(9×6)+(6×1)=64.\begin{align*}\mathbb{V}[X + 3Y] & = \mathbb{V}[X] + \mathbb{V}[3Y] + 2 \Cov(X, 3Y) \\ & = \mathbb{V}[X] + 9 \mathbb{V}[Y] + 6 \Cov(X, Y) = 4 + (9 \times 6) + (6 \times 1) = 64.\end{align*}

More generally, given a kk-dimensional Gaussian random vector XN(μ,Σ)X \sim \mathcal{N}(\mu, \Sigma), you can think of each entry XiX_i of XX as:

Xi=μi+j=1kaijZj,  where ZjN(0,1)  for all j=1,,k.X_i = \mu_i + \sum_{j = 1}^k a_{ij} Z_j, ~ \text{ where } Z_j \sim \mathcal{N}(0, 1) ~ \text{ for all } j = 1, \dots, k.

Importantly, the ZjZ_j are all independent, so computing something like V[X13X24+X5X7X8]\mathbb{V}[X_1^3X_2^4 + X_5X_7X_8] cannot be hard: substitute each XiX_i with the appropriate linear combination of the independent ZjZ_j, and the rest must be trivial.

Example. Consider a random vector distributed as (XY)N((32),(4116))\begin{pmatrix} X \\ Y \end{pmatrix} \sim \mathcal{N}\left(\begin{pmatrix} 3 \\ 2 \end{pmatrix}, \begin{pmatrix} 4 & 1 \\ 1 & 6 \end{pmatrix}\right). Compute E[XX+Y=6]\mathbb{E}[X \mid X + Y = 6].

Solution: This one requires us to use the Gaussian-ness of the distribution. Here's how.

Lemma. Suppose XX and YY are jointly Gaussian random variables. Then Cov(X,Y)=0\Cov(X, Y) = 0 implies XYX \perp Y.

Proof: If Cov(X,Y)=0\Cov(X, Y) = 0, then (XY)N((μXμY),(σX200σY2))\begin{pmatrix} X \\ Y \end{pmatrix} \sim \mathcal{N}\left(\begin{pmatrix} \mu_X \\ \mu_Y \end{pmatrix}, \begin{pmatrix} \sigma_X^2 & 0 \\ 0 & \sigma_Y^2 \end{pmatrix}\right), so the joint density of XX and YY looks like:

f(x,y)=12πσXσYexp((xμX)22σX2(yμY)22σY2)=(1σX2πexp((xμX)22σX2))fX(x)(1σY2πexp((yμY)22σY2))fY(y)=fX(x)fY(y).\begin{align*}f(x, y) & = \frac{1}{2\pi \sigma_X \sigma_Y} \exp\left(-\frac{(x - \mu_X)^2}{2\sigma_X^2} - \frac{(y - \mu_Y)^2}{2\sigma_Y^2}\right) \\ & = \underbrace{\left(\frac{1}{\sigma_X \sqrt{2\pi}} \exp\left(-\frac{(x - \mu_X)^2}{2\sigma_X^2}\right)\right)}_{f_X(x)} \cdot \underbrace{\left(\frac{1}{\sigma_Y \sqrt{2\pi}} \exp\left(-\frac{(y - \mu_Y)^2}{2\sigma_Y^2}\right)\right)}_{f_Y(y)} = f_X(x) \cdot f_Y(y).\end{align*}

The point is that jointly Gaussian PDFs factor nicely when Cov(X,Y)=0\Cov(X, Y) = 0, which implies XYX \perp Y.   \blacksquare

(When XX and YY are not jointly Gaussian, a counterexample is XN(0,1)X \sim \mathcal{N}(0, 1) and Y=ZXY = ZX, where ZUnif{1,1}Z \sim \mathrm{Unif}\{-1, 1\} is a coin flip independent of XX.)

Back to the original problem. First, a simplification: take S:=X+YS := X + Y, so (XS)=(1011)(XY)\begin{pmatrix} X \\ S \end{pmatrix} = \begin{pmatrix} 1 & 0 \\ 1 & 1 \end{pmatrix} \begin{pmatrix} X \\ Y \end{pmatrix}, which implies:

(XS)N((1011)(32),(1011)(4116)(1011))=N((35),(45512)).\begin{pmatrix} X \\ S \end{pmatrix} \sim \mathcal{N}\left( \begin{pmatrix} 1 & 0 \\ 1 & 1 \end{pmatrix} \begin{pmatrix} 3 \\ 2 \end{pmatrix}, \begin{pmatrix} 1 & 0 \\ 1 & 1 \end{pmatrix} \begin{pmatrix} 4 & 1 \\ 1 & 6 \end{pmatrix} \begin{pmatrix} 1 & 0 \\ 1 & 1 \end{pmatrix}^{\top}\right) = \mathcal{N}\left( \begin{pmatrix} 3 \\ 5 \end{pmatrix}, \begin{pmatrix} 4 & 5 \\ 5 & 12 \end{pmatrix} \right).

(Perhaps a quicker way to find the new covariance matrix is just to compute Var(X)\Var(X), Cov(X,S)\Cov(X, S), and Var(S)\Var(S).)

We now seek E[XS=6]\mathbb{E}[X \mid S = 6]. The trick is to apply the lemma so as to get rid of the conditional:

Cov(XCov(X,S)Var(S)S,S)=0     (XCov(X,S)Var(S)S)S.\Cov\left(X - \frac{\Cov(X, S)}{\Var(S)}\cdot S, S\right) = 0 ~ \implies \left(X - \frac{\Cov(X, S)}{\Var(S)} \cdot S\right) \perp S.

Reading off Cov(X,S)=5\Cov(X, S) = 5 and Var(S)=12\Var(S) = 12, we can now finish the job:

E[XS=6]=E[X512SS=6]E[X512S]+E[512SS=6]512(6)=3512×5+52=4112.\begin{align*}\mathbb{E}[X \mid S = 6] = \underbrace{\mathbb{E}\left[ X - \frac{5}{12}S \mid S = 6 \right]}_{ \mathbb{E}\left[ X - \frac{5}{12}S \right] } + \underbrace{\mathbb{E}\left[ \frac{5}{12}S \mid S = 6 \right]}_{ \frac{5}{12}(6) } = 3 - \frac{5}{12} \times 5 + \frac{5}{2} = \frac{41}{12}.\end{align*}

In the more general case, computing something like E[XXY=7]\mathbb{E}[X \mid XY = 7] is not reasonable, even for jointly Gaussian distributions.