Post · 5 min read· pp. 30–33

Multivariate Gaussian and Covariance Matrix

Introduction

In ordinary probability theory courses, the course instructor would usually not emphasize the concepts and properties of the multivariate Gaussian distribution. However, multivariate Gaussian distribution is actually quite widely used in many different models. So here we are going to fill some holes in the probability theory we learned.

Multivariate Gaussian Distribution

If a random vector variable xx follows a multivariate Gaussian distribution with mean μ\mu and covariance matrix Σ\Sigma, its probability density function (pdf) is given by:

p(x;μ,Σ)=1(2π)n/2∣Σ∣1/2exp⁡(−12(x−μ)TΣ−1(x−μ))p(x; \mu, \Sigma) = \frac{1}{(2\pi)^{n/2} |\Sigma|^{1/2}} \exp{(-\frac{1}{2}(x-\mu)^T \Sigma^{-1} (x-\mu))}

We write this as x∼N(μ,Σ)x \sim \mathcal{N}(\mu, \Sigma).

To understand the multivariate Gaussian distribution properly, we need to first understand the covariance matrix.

Covariance Matrix

Covariance is actually the critical part of multivariate Gaussian distribution. We will first look at some of the properties of the covariance matrix and try to prove them.

The two major properties of the covariance matrix are:

  • Covariance matrix is positive semi-definite.
  • Covariance matrix in multivariate Gaussian distribution is positive definite.

A symmetric matrix MM is said to be positive semi-definite if yTMyy^TMy is always non-negative for any vector yy.

Similarly, a symmetric matrix MM is said to be positive definite if yTMyy^TMy is always positive for any non-zero vector yy.

Covariance matrix is positive semi-definite

We will first see the covariance matrix is positive semi-definite.

By definition, given a random vector xx, the covariance matrix is:

Σ=E[(x−μ)(x−μ)T]\Sigma = E[(x-\mu)(x-\mu)^T]

For any vector vv, we have:

vTΣv=vTE[(x−μ)(x−μ)T]v=E[((x−μ)Tv)T((x−μ)Tv)]=E[((x−μ)Tv)2]≥0v^T \Sigma v = v^T E[(x-\mu)(x-\mu)^T] v = E[((x-\mu)^T v)^T ((x-\mu)^T v)] = E[((x-\mu)^T v)^2] \geq 0

Therefore, the covariance matrix is positive semi-definite.

Covariance matrix in multivariate Gaussian distribution is positive definite

Now we need to see why the covariance matrix in multivariate Gaussian distribution is positive definite.

Notice from the pdf of the multivariate Gaussian distribution that the covariance matrix Σ\Sigma must be invertible, otherwise the pdf does not exist.

Because Σ\Sigma is invertible, it must be full rank, and linear system Σx=0\Sigma x = 0 only has single solution x=0x = 0.

From Lemma 2, because Σ\Sigma is symmetric, we know that Σ\Sigma could be decomposed as Σ=BTB\Sigma = B^T B.

Therefore, for any non-zero vector yy, yTΣy=0y^T \Sigma y = 0 if and only if By=0By = 0. Because yTΣy=yTBTBy=(By)T(By)y^T \Sigma y = y^T B^T B y = (By)^T (By). If By=0By = 0, Σy=BTBy=0\Sigma y = B^T By = 0. Because Σ\Sigma is full rank, and y≠0y \neq 0, there is no solution for linear system yTΣy=0y^T \Sigma y = 0. Therefore, yTΣy>0y^T \Sigma y > 0 and Σ\Sigma is positive definite.

Significance

From Lemma 3, we know that Σ−1\Sigma^{-1} is also positive definite.

We have proved all the way to show that Σ−1\Sigma^{-1} is positive definite, why would we need to know this?

In the pdf of multivariate Gaussian, (x−μ)TΣ−1(x−μ)(x-\mu)^T \Sigma^{-1} (x-\mu) is always greater than 0, and exp⁡(−12(x−μ)TΣ−1(x−μ))\exp{(-\frac{1}{2}(x-\mu)^T \Sigma^{-1} (x-\mu))} is always less than 1.

Multivariate Gaussian Distribution Properties

We now could move to learn some Gaussian distribution properties.

Gaussian Properties

  1. The sum of independent Gaussian random variables is Gaussian.
  2. The marginal of a joint Gaussian distribution is Gaussian.
  3. The conditional of a joint Gaussian distribution is Gaussian.

The proofs of these properties are rather complicated. The references to these proofs are provided in reference 2.

Example Facts

Suppose the real, scalar random variables XX, YY, and ZZ are jointly Gaussian. We could infer that:

  1. XX, YY, and ZZ independently are Gaussians because of the Gaussian property 2.
  2. 2X+Y−Z2X+Y-Z is Gaussian because of the Gaussian property 1 and example fact 1.
  3. X∣YX|Y is Gaussian because of the Gaussian property 3.
  4. X∣Y,ZX|Y,Z is Gaussian.

The example fact 4 might not be obvious. Here we could show using the Gaussian property 3 and conditional probability theorem without formal proof.

Because p(X∣Y,Z)=p(X∣Y)×p(Y∣Z)p(X|Y,Z) = p(X|Y) \times p(Y|Z), p(X∣Y)p(X|Y) and p(Y∣Z)p(Y|Z) are the pdf of Gaussian distribution we know from the Gaussian property 3. The product of two Gaussian pdf is a pdf of a new Gaussian (Demo and formal proof).

Lemmas

These are the lemmas that I proved to support part of the statements in this blog post.

Lemma 1

A symmetric matrix is positive definite if and only if its eigenvalues are all positive.

Proof

Any square symmetric matrix MM could be eigendecomposed (Wikipedia). M=P−1DP=PTDPM = P^{-1}DP = P^TDP (For symmetric matrix, PP is orthonormal, P−1=PTP^{-1} = P^T) where DD is the diagonal eigenvalue matrix. yTMy=yTPTDPy=(Py)TD(Py)y^TMy = y^TP^TDPy = (Py)^TD(Py). Because DD is diagonal, (Py)T(Py)(Py)^T(Py) is non-negative, therefore, MM is positive definite if and only if all the diagonal elements, i.e., the eigenvalues of MM, are positive.

Lemma 2

A symmetric matrix AA could be decomposed as A=BTBA = B^T B where BB is also a square matrix

Proof

A=PTDP=PT(D1/2)TD1/2P=(D1/2P)T(D1/2P)=BTBA = P^TDP = P^T (D^{1/2})^T D^{1/2} P = (D^{1/2} P)^T (D^{1/2} P) = B^T B

where B=D1/2PB = D^{1/2} P

Lemma 3

If matrix KK is positive definite, then K−1K^{-1} is also positive definite.

Proof

From Lemma 1, we know that if KK is positive definite, all the eigenvalues of KK is positive. Therefore, the determinant of KK is positive, and KK must be invertible.

For any vector non-zero yy, we could always express yy as y=Kxy = Kx because KK is invertible. Given KK is positive definite and vTKv>0v^T K v > 0 for any non-zero vector vv.

Then we have:

yTK−1y=(Kx)TK−1Kx=xTKT(K−1K)x=xTKTx=(xTKx)T>0y^T K^{-1} y = (Kx)^T K^{-1} Kx = x^T K^T (K^{-1} K) x = x^T K^T x = (x^T K x)^T > 0

Therefore, K−1K^{-1} is also positive definite.

References

The references below provide a lot of useful properties and facts without showing some of the detailed self-contained subtle proofs I provided above.