Multivariate Gaussians are often presented as intimidating objects. The density function looks kind of scary:

f(x)=1(2π)ndet⁡(Σ)exp⁡(−12(x−μ)⊤Σ−1(x−μ)).f(\mathbf{x}) = \frac{1}{\sqrt{(2\pi)^n \det(\boldsymbol{\Sigma})}} \exp\left( -\frac{1}{2} (\mathbf{x} - \boldsymbol{\mu})^{\top} \boldsymbol{\Sigma}^{-1} (\mathbf{x} - \boldsymbol{\mu}) \right).

But there’s a clearer perspective: any multivariate Gaussian can be disentangled into independent 1-dimensional Gaussians. More precisely, there’s always a basis in which a multivariate Gaussian has independent coordinates. This basis is given by the eigenbasis of the covariance matrix, and the eigenvalues correspond to the variances along each axis.

Random vectors

Let x=(x1,…,xk)⊤∈Rk\mathbf{x} = (x_1, \ldots, x_k)^{\top} \in \mathbb{R}^{k} be a random vector. The expectation and covariance of x\mathbf{x} can be written as follows:

E[x]=(E[x1],…,E[xk])⊤,\mathbb{E}[\mathbf{x}] = \left(\mathbb{E}[x_1], \ldots, \mathbb{E}[x_k]\right)^{\top}, Cov(x)=E[(x−E[x])(x−E[x])⊤].\text{Cov}(\mathbf{x}) = \mathbb{E}\left[\left(\mathbf{x} - \mathbb{E}[\mathbf{x}]\right)\left(\mathbf{x} - \mathbb{E}[\mathbf{x}]\right)^{\top}\right].

Note that the covariance matrix Cov(x)\text{Cov}(\mathbf{x}) is symmetric and positive semi-definite. To see this, let’s fix some vector a∈Rk\mathbf{a} \in \mathbb{R}^{k} and consider a⊤Cov(x)a\mathbf{a}^{\top} \text{Cov}(\mathbf{x}) \mathbf{a}:

a⊤Cov(x)a=a⊤E[(x−E[x])(x−E[x])⊤]a=E[a⊤(x−E[x])(x−E[x])⊤a]=E[(a⊤(x−E[x]))2]≥0.\begin{aligned} \mathbf{a}^{\top} \text{Cov}(\mathbf{x}) \mathbf{a} &= \mathbf{a}^{\top} \mathbb{E}\left[\left(\mathbf{x} - \mathbb{E}[\mathbf{x}]\right)\left(\mathbf{x} - \mathbb{E}[\mathbf{x}]\right)^{\top}\right] \mathbf{a} \\ &= \mathbb{E}\left[\mathbf{a}^{\top} \left(\mathbf{x} - \mathbb{E}[\mathbf{x}]\right)\left(\mathbf{x} - \mathbb{E}[\mathbf{x}]\right)^{\top} \mathbf{a}\right] \\ &= \mathbb{E}\left[(\mathbf{a}^{\top} (\mathbf{x} - \mathbb{E}[\mathbf{x}]))^2\right] \\ &\geq 0. \end{aligned}

If we multiply a random vector x∈Rk\mathbf{x} \in \mathbb{R}^{k} by a matrix A∈Rn×k\mathbf{A} \in \mathbb{R}^{n \times k}, then the covariance of the resulting random vector y=Ax∈Rn\mathbf{y} = \mathbf{A}\mathbf{x} \in \mathbb{R}^{n} is given by:

Cov(y)=E[(y−E[y])(y−E[y])⊤]=E[(Ax−AE[x])(Ax−AE[x])⊤]=E[A(x−E[x])(x−E[x])⊤A⊤]=AE[(x−E[x])(x−E[x])⊤]A⊤=ACov(x)A⊤.\begin{aligned} \text{Cov}(\mathbf{y}) &= \mathbb{E}\left[\left(\mathbf{y} - \mathbb{E}[\mathbf{y}]\right)\left(\mathbf{y} - \mathbb{E}[\mathbf{y}]\right)^{\top}\right] \\ &= \mathbb{E}\left[\left(\mathbf{A}\mathbf{x} - \mathbf{A}\mathbb{E}[\mathbf{x}]\right)\left(\mathbf{A}\mathbf{x} - \mathbf{A}\mathbb{E}[\mathbf{x}]\right)^{\top}\right] \\ &= \mathbb{E}\left[\mathbf{A}\left(\mathbf{x} - \mathbb{E}[\mathbf{x}]\right)\left(\mathbf{x} - \mathbb{E}[\mathbf{x}]\right)^{\top} \mathbf{A}^{\top}\right] \\ &= \mathbf{A} \mathbb{E}\left[\left(\mathbf{x} - \mathbb{E}[\mathbf{x}]\right)\left(\mathbf{x} - \mathbb{E}[\mathbf{x}]\right)^{\top}\right] \mathbf{A}^{\top} \\ &= \mathbf{A} \text{Cov}(\mathbf{x}) \mathbf{A}^{\top}. \end{aligned}

Multivariate Gaussian distribution

Now we can define the multivariate Gaussian distribution.

Let g=(g1,…,gk)⊤∈Rk\mathbf{g} = (g_1, \ldots, g_k)^{\top} \in \mathbb{R}^{k} be a vector of i.i.d. standard normal random variables. Given a matrix A∈Rn×k\mathbf{A} \in \mathbb{R}^{n \times k}, the covariance of Ag\mathbf{A}\mathbf{g} is ACov(g)A⊤=AIA⊤=AA⊤\mathbf{A} \text{Cov}(\mathbf{g}) \mathbf{A}^{\top} = \mathbf{A} \mathbf{I} \mathbf{A}^{\top} = \mathbf{A} \mathbf{A}^{\top}.

The distribution of Ag\mathbf{A}\mathbf{g} is called a multivariate normal distribution with covariance Σ=AA⊤\boldsymbol{\Sigma} = \mathbf{A} \mathbf{A}^{\top}, denoted N(0,Σ)\mathcal{N}(\mathbf{0}, \boldsymbol{\Sigma}).

Since Σ\boldsymbol{\Sigma} is symmetric positive semi-definite, we can write its eigendecomposition as

Σ=QΛQ⊤,\boldsymbol{\Sigma} = \mathbf{Q} \boldsymbol{\Lambda} \mathbf{Q}^{\top},

where Q∈Rn×n\mathbf{Q} \in \mathbb{R}^{n \times n} is an orthogonal matrix, and Λ∈Rn×n\boldsymbol{\Lambda} \in \mathbb{R}^{n \times n} is a diagonal matrix with eigenvalues λ1,…,λn\lambda_1, \ldots, \lambda_n on the diagonal.

Now we can take

A=QΛ1/2orA=QΛ1/2Q⊤\mathbf{A} = \mathbf{Q} \boldsymbol{\Lambda}^{1/2} \quad \text{or} \quad \mathbf{A} = \mathbf{Q} \boldsymbol{\Lambda}^{1/2} \mathbf{Q}^{\top}

so that AA⊤=QΛ1/2Λ1/2Q⊤=QΛQ⊤=Σ\mathbf{A} \mathbf{A}^{\top} = \mathbf{Q} \boldsymbol{\Lambda}^{1/2} \boldsymbol{\Lambda}^{1/2} \mathbf{Q}^{\top} = \mathbf{Q} \boldsymbol{\Lambda} \mathbf{Q}^{\top} = \boldsymbol{\Sigma}.

For example, take x=QΛ1/2g\mathbf{x} = \mathbf{Q} \boldsymbol{\Lambda}^{1/2} \mathbf{g} for g∼N(0,I)\mathbf{g} \sim \mathcal{N}(\mathbf{0}, \mathbf{I}). Then x∼N(0,Σ)\mathbf{x} \sim \mathcal{N}(\mathbf{0}, \boldsymbol{\Sigma}).

Visualizing the transformation x=QΛ1/2g\mathbf{x} = \mathbf{Q}\boldsymbol{\Lambda}^{1/2}\mathbf{g}
1. Start: g ~ N(0, I)
i.i.d. standard normals
→
2. Scale: Λ1/2g
stretch by λ₁1/2, λ₂1/2
→
3. Rotate: QΛ1/2g
align to q₁, q₂

Disentangling the multivariate Gaussian

Now label q1,…,qn\mathbf{q}_1, \ldots, \mathbf{q}_n as the columns of Q\mathbf{Q}.

Expanding x=QΛ1/2g\mathbf{x} = \mathbf{Q} \boldsymbol{\Lambda}^{1/2} \mathbf{g}:

x=λ1g1q1+…+λngnqn=∑i=1nλigiqi.\mathbf{x} = \sqrt{\lambda_1} g_1 \mathbf{q}_1 + \ldots + \sqrt{\lambda_n} g_n \mathbf{q}_n = \sum_{i=1}^{n} \sqrt{\lambda_i} g_i \mathbf{q}_i.

In the orthonormal basis q1,…,qn\mathbf{q}_1, \ldots, \mathbf{q}_n, the vector x\mathbf{x} has coordinates (λ1g1,…,λngn)(\sqrt{\lambda_1} g_1, \ldots, \sqrt{\lambda_n} g_n). These coordinates are independent 1-dimensional Gaussian random variables, with variances λ1,…,λn\lambda_1, \ldots, \lambda_n.

If Σ\boldsymbol{\Sigma} is singular (i.e. det⁡Σ=0\det \boldsymbol{\Sigma} = 0), some eigenvalues will be zero, say λk+1=…=λn=0\lambda_{k+1} = \ldots = \lambda_n = 0. The random vector is then concentrated on the subspace spanned by q1,…,qk\mathbf{q}_1, \ldots, \mathbf{q}_k, and has no density on Rn\mathbb{R}^n. On this subspace, x\mathbf{x} has density (in the eigenbasis coordinates):

f(x1,…,xk)=∏i=1k12πλiexp⁡(−xi22λi).f(x_1, \ldots, x_k) = \prod_{i=1}^{k} \frac{1}{\sqrt{2\pi\lambda_i}} \exp\left( -\frac{x_i^2}{2\lambda_i} \right).

References

References are listed in alphabetical order.

  1. Lecture 4: Multivariate normal distribution and multivariate CLT [link]
    Dmitry Panchenko. 2006.