# Multivariate normal distribution

MVN redirects here. For the airport with that IATA code in Mount Vernon, Kentucky, see Mount Vernon Airport.
Parameters Probability density function Cumulative distribution function ${\displaystyle \mu =[\mu _{1},\dots ,\mu _{N}]^{T}}$ location (real vector)${\displaystyle \Sigma }$ covariance matrix (positive-definite real ${\displaystyle N\times N}$ matrix) ${\displaystyle x\in \mathbb {R} ^{N}\!}$ ${\displaystyle f_{X}(x_{1},\dots ,x_{N})={\frac {1}{(2\pi )^{N/2}\left|\Sigma \right|^{1/2}}}}$${\displaystyle \exp \left(-{\frac {1}{2}}(x-\mu )^{\top }\Sigma ^{-1}(x-\mu )\right)}$ ${\displaystyle \mu }$ ${\displaystyle \mu }$ ${\displaystyle \mu }$ ${\displaystyle \Sigma }$ (covariance matrix) 0 0 ${\displaystyle \ln \left({\sqrt {(2\,\pi \,e)^{N}\left|\Sigma \right|}}\right)\!}$ ${\displaystyle M_{X}(t)=\exp \left(\mu ^{\top }t+{\frac {1}{2}}t^{\top }\Sigma t\right)}$ ${\displaystyle \phi _{X}(t;\mu ,\Sigma )=\exp \left(i\mu ^{\top }t-{\frac {1}{2}}t^{\top }\Sigma t\right)}$

In probability theory and statistics, a multivariate normal distribution, also sometimes called a multivariate Gaussian distribution, is a specific probability distribution, which can be thought of as a generalization to higher dimensions of the one-dimensional normal distribution (also called a Gaussian distribution). It is also closely related to matrix normal distribution.

## General case

A random vector ${\displaystyle \ X=[X_{1},\dots ,X_{N}]^{T}}$ follows a multivariate normal distribution if it satisfies the following equivalent conditions:

• every linear combination ${\displaystyle \ Y=a_{1}X_{1}+\cdots +a_{N}X_{N}}$ is normally distributed
• there is a random vector ${\displaystyle \ Z=[Z_{1},\dots ,Z_{M}]^{T}}$, whose components are independent standard normal random variables, a vector ${\displaystyle \ \mu =[\mu _{1},\dots ,\mu _{N}]^{T}}$ and an ${\displaystyle N\times M}$ matrix ${\displaystyle \ A}$ such that ${\displaystyle \ X=AZ+\mu }$.
• there is a vector ${\displaystyle \mu }$ and a symmetric, positive semi-definite matrix ${\displaystyle \ \Sigma }$ such that the characteristic function of X is
${\displaystyle \phi _{X}\left(u;\mu ,\Sigma \right)=\exp \left(i\mu ^{\top }u-{\frac {1}{2}}u^{\top }\Sigma u\right).}$

If ${\displaystyle \ \Sigma }$ is non-singular, then the distribution may be described by the following PDF:

${\displaystyle f_{X}(x_{1},\dots ,x_{N})={\frac {1}{(2\pi )^{N/2}|\Sigma |^{1/2}}}\exp \left(-{\frac {1}{2}}(x-\mu )^{\top }\Sigma ^{-1}(x-\mu )\right)}$

where ${\displaystyle \ \left|\Sigma \right|}$ is the determinant of ${\displaystyle \ \Sigma }$. Note how the equation above reduces to that of the univariate normal distribution if ${\displaystyle \ \Sigma }$ is a scalar (i.e., a multiple of the identity matrix).

The vector μ in these conditions is the expected value of X and the matrix ${\displaystyle \ \Sigma =AA^{T}}$ is the covariance matrix of the components Xi.

It is important to realize that the covariance matrix must be allowed to be singular (thus not described by above formula for which ${\displaystyle \ \Sigma ^{-1}}$ is defined). That case arises frequently in statistics; for example, in the distribution of the vector of residuals in ordinary linear regression problems. Note also that the Xi are in general not independent; they can be seen as the result of applying the linear transformation A to a collection of independent Gaussian variables Z.

That the distribution of a random vector X is a multivariate normal distribution can be written in the following notation:

${\displaystyle X\ \sim {\mathcal {N}}(\mu ,\Sigma ),}$

or to make it explicitly known that X is N-dimensional,

${\displaystyle X\ \sim {\mathcal {N}}_{N}(\mu ,\Sigma ).}$

### Cumulative distribution function

The cumulative distribution function (cdf) ${\displaystyle F(x)}$ is defined as the probability that all values in a random vector ${\displaystyle X}$ are less than or equal to the corresponding values in vector ${\displaystyle x}$. Though there is no closed form for ${\displaystyle F(x)}$, there are a number of algorithms that estimate it numerically. For example, see MVNDST under [1] (includes FORTRAN code) or [2] (includes MATLAB code).

### A counterexample

The fact that two or more random variables X and Y are normally distributed does not imply that the pair (XY) has a joint normal distribution. A simple example is one in which Y = X if |X| > 1 and Y = −X if |X| < 1.

### Normally distributed and independent

If X and Y are normally distributed and independent, then they are "jointly normally distributed", i.e., the pair (XY) has a bivariate normal distribution. There are of course also many bivariate normal distributions in which the components are correlated.

## Bivariate case

In the 2-dimensional nonsingular case, the probability density function (with mean (0,0)) is

${\displaystyle f(x,y)={\frac {1}{2\pi \sigma _{x}\sigma _{y}{\sqrt {1-\rho ^{2}}}}}\exp \left(-{\frac {1}{2(1-\rho ^{2})}}\left({\frac {x^{2}}{\sigma _{x}^{2}}}+{\frac {y^{2}}{\sigma _{y}^{2}}}-{\frac {2\rho xy}{(\sigma _{x}\sigma _{y})}}\right)\right)}$

where ${\displaystyle \rho }$ is the correlation between ${\displaystyle X}$ and ${\displaystyle Y}$. In this case,

${\displaystyle \Sigma ={\begin{bmatrix}\sigma _{x}^{2}&\rho \sigma _{x}\sigma _{y}\\\rho \sigma _{x}\sigma _{y}&\sigma _{y}^{2}\end{bmatrix}}.}$

## Linear transformation

If ${\displaystyle Y=BX\,}$ is a linear transformation of ${\displaystyle X\ \sim {\mathcal {N}}(\mu ,\Sigma ),}$ where ${\displaystyle B\,}$ is an ${\displaystyle M\times N}$ matrix then ${\displaystyle Y\,}$ has a multivariate normal distribution with expected value ${\displaystyle B\mu \,}$ and variance ${\displaystyle B\Sigma B^{T}\,}$ (i.e., ${\displaystyle Y\sim {\mathcal {N}}\left(B\mu ,B\Sigma B^{T}\right)}$).

Corollary: any subset of the ${\displaystyle X_{i}\,}$ has a marginal distribution that is also multivariate normal. To see this consider the following example: to extract the subset ${\displaystyle (X_{1},X_{2},X_{4})^{T}\,}$, use

${\displaystyle B={\begin{bmatrix}1&0&0&0&0&\ldots &0\\0&1&0&0&0&\ldots &0\\0&0&0&1&0&\ldots &0\end{bmatrix}}}$

which extracts the desired elements directly.

## Geometric interpretation

The equidensity contours of a non-singular multivariate normal distribution are ellipsoids (i.e. linear transformations of hyperspheres) centered at the mean[1]. The directions of the principal axes of the ellipsoids are given by the eigenvectors of the covariance matrix ${\displaystyle \Sigma }$. The squared relative lengths of the principal axes are given by the corresponding eigenvalues.

If ${\displaystyle \Sigma =U\Lambda U^{T}=U\Lambda ^{1/2}(U\Lambda ^{1/2})^{T}}$ is an eigendecomposition where the columns of U are unit eigenvectors and ${\displaystyle \Lambda }$ is a diagonal matrix of the eigenvalues, then we have

${\displaystyle X\ \sim N(\mu ,\Sigma )\iff X\ \sim \mu +U\Lambda ^{1/2}N(0,I)\iff X\ \sim \mu +UN(0,\Lambda ).}$

Moreover, U can be chosen to be a rotation matrix, as inverting an axis does not have any effect on ${\displaystyle N(0,\Lambda )}$, but inverting a column changes the sign of U's determinant. The distribution ${\displaystyle N(\mu ,\Sigma )}$ is in effect ${\displaystyle N(0,I)}$ scaled by ${\displaystyle \Lambda ^{1/2}}$, rotated by U and translated by ${\displaystyle \mu }$.

Conversely, any choice of ${\displaystyle \mu }$, full rank matrix U, and positive diagonal entries ${\displaystyle \Lambda _{i}}$ yields a non-singular multivariate normal distribution. If any ${\displaystyle \Lambda _{i}}$ is zero and U is square, the resulting covariance matrix ${\displaystyle U\Lambda U^{T}}$ is singular. Geometrically this means that every contour ellipsoid is infinitely thin and has zero volume in n-dimensional space, as at least one of the principal axes has length of zero.

## Correlations and independence

In general, random variables may be uncorrelated but highly dependent. But if a random vector has a multivariate normal distribution then any two or more of its components that are uncorrelated are independent. This implies that any two or more of its components that are pairwise independent are independent.

But it is not true that two random variables that are (separately, marginally) normally distributed and uncorrelated are independent. Two random variables that are normally distributed may fail to be jointly normally distributed, i.e., the vector whose components they are may fail to have a multivariate normal distribution. For an example of two normally distributed random variables that are uncorrelated but not independent, see normally distributed and uncorrelated does not imply independent.

## Higher moments

The kth-order moments of X are defined by

${\displaystyle \mu _{1,\dots ,N}(X)\ {\stackrel {\mathrm {def} }{=}}\ \mu _{r_{1},\dots ,r_{N}}(X)\ {\stackrel {\mathrm {def} }{=}}\ E\left[\prod \limits _{j=1}^{N}X_{j}^{r_{j}}\right]}$

where ${\displaystyle r_{1}+r_{2}+\cdots +r_{N}=k.}$

The central ${\displaystyle k}$-order moments are given as follows

(a) If ${\displaystyle k}$ is odd, ${\displaystyle \mu _{1,\dots ,N}(X-\mu )=0}$.

(b) If ${\displaystyle k}$ is even with ${\displaystyle k=2\lambda }$, then

${\displaystyle \mu _{1,\dots ,2\lambda }(X-\mu )=\sum \left(\sigma _{ij}\sigma _{kl}\cdots \sigma _{XZ}\right)}$

where the sum is taken over all allocations of the set ${\displaystyle \left\{1,\dots ,2\lambda \right\}}$ into ${\displaystyle \lambda }$ (unordered) pairs, giving ${\displaystyle (2\lambda -1)!/(2^{\lambda -1}(\lambda -1)!)}$ terms in the sum, each being the product of ${\displaystyle \lambda }$ covariances. The covariances are determined by replacing the terms of the list ${\displaystyle \left[1,\dots ,2\lambda \right]}$ by the corresponding terms of the list consisting of ${\displaystyle r_{1}}$ ones, then ${\displaystyle r_{2}}$ twos, etc, after each of the possible allocations of the former list into pairs.

In particular, the 4-order moments are

${\displaystyle E\left[X_{i}^{4}\right]=3(\sigma _{ii})^{2}}$
${\displaystyle E\left[X_{i}^{3}X_{j}\right]=3\sigma _{ii}\sigma _{ij}}$
${\displaystyle E\left[X_{i}^{2}X_{j}^{2}\right]=\sigma _{ii}\sigma _{jj}+2\left(\sigma _{ij}\right)^{2}}$
${\displaystyle E\left[X_{i}^{2}X_{j}X_{k}\right]=\sigma _{ii}\sigma _{jk}+2\sigma _{ij}\sigma _{ik}}$
${\displaystyle E\left[X_{i}X_{j}X_{k}X_{n}\right]=\sigma _{ij}\sigma _{kn}+\sigma _{ik}\sigma _{jn}+\sigma _{in}\sigma _{jk}.}$

For fourth order moments (four variables) there are three terms. For sixth-order moments there are 3 × 5 = 15 terms, and for eighth-order moments there are 3 × 5 × 7 = 105 terms. The sixth-order moment case can be expanded as

{\displaystyle {\begin{aligned}&{}E[X_{1}X_{2}X_{3}X_{4}X_{5}X_{6}]\\&{}=E[X_{1}X_{2}]E[X_{3}X_{4}]E[X_{5}X_{6}]+E[X_{1}X_{2}]E[X_{3}X_{5}]E[X_{4}X_{6}]+E[X_{1}X_{2}]E[X_{3}X_{6}]E[X_{4}X_{5}]\\&{}+E[X_{1}X_{3}]E[X_{2}X_{4}]E[X_{5}X_{6}]+E[X_{1}X_{3}]E[X_{2}X_{5}]E[X_{4}X_{6}]+E[X_{1}X_{3}]E[X_{2}X_{6}]E[X_{4}X_{5}]\\&+E[X_{1}X_{4}]E[X_{2}X_{3}]E[X_{5}X_{6}]+E[X_{1}X_{4}]E[X_{2}X_{5}]E[X_{3}X_{6}]+E[X_{1}X_{4}]E[X_{2}X_{6}]E[X_{3}X_{5}]\\&+E[X_{1}X_{5}]E[X_{2}X_{3}]E[X_{4}X_{6}]+E[X_{1}X_{5}]E[X_{2}X_{4}]E[X_{3}X_{6}]+E[X_{1}X_{5}]E[X_{2}X_{6}]E[X_{3}X_{4}]\\&+E[X_{1}X_{6}]E[X_{2}X_{3}]E[X_{4}X_{5}]+E[X_{1}X_{6}]E[X_{2}X_{4}]E[X_{3}X_{5}]+E[X_{1}X_{6}]E[X_{2}X_{5}]E[X_{3}X_{4}].\end{aligned}}}

## Conditional distributions

If ${\displaystyle \mu }$ and ${\displaystyle \Sigma }$ are partitioned as follows

${\displaystyle \mu ={\begin{bmatrix}\mu _{1}\\\mu _{2}\end{bmatrix}}\quad }$ with sizes ${\displaystyle {\begin{bmatrix}q\times 1\\(N-q)\times 1\end{bmatrix}}}$
${\displaystyle \Sigma ={\begin{bmatrix}\Sigma _{11}&\Sigma _{12}\\\Sigma _{21}&\Sigma _{22}\end{bmatrix}}\quad }$ with sizes ${\displaystyle {\begin{bmatrix}q\times q&q\times (N-q)\\(N-q)\times q&(N-q)\times (N-q)\end{bmatrix}}}$

then the distribution of ${\displaystyle x_{1}}$ conditional on ${\displaystyle x_{2}=a}$ is multivariate normal ${\displaystyle (X_{1}|X_{2}=a)\sim N({\bar {\mu }},{\overline {\Sigma }})}$ where

${\displaystyle {\bar {\mu }}=\mu _{1}+\Sigma _{12}\Sigma _{22}^{-1}\left(a-\mu _{2}\right)}$

and covariance matrix

${\displaystyle {\overline {\Sigma }}=\Sigma _{11}-\Sigma _{12}\Sigma _{22}^{-1}\Sigma _{21}.}$

This matrix is the Schur complement of ${\displaystyle {\mathbf {\Sigma } _{22}}}$ in ${\displaystyle {\mathbf {\Sigma } }}$.

Note that knowing the value of ${\displaystyle x_{2}}$ to be ${\displaystyle a}$ alters the variance; perhaps more surprisingly, the mean is shifted by ${\displaystyle \Sigma _{12}\Sigma _{22}^{-1}\left(a-\mu _{2}\right)}$; compare this with the situation of not knowing the value of ${\displaystyle a}$, in which case ${\displaystyle x_{1}}$ would have distribution ${\displaystyle N_{q}\left(\mu _{1},\Sigma _{11}\right)}$.

The matrix ${\displaystyle \Sigma _{12}\Sigma _{22}^{-1}}$ is known as the matrix of regression coefficients.

## Fisher information matrix

The Fisher information matrix (FIM) for a normal distribution takes a special formulation. The ${\displaystyle (m,n)}$ element of the FIM for ${\displaystyle X\sim N(\mu (\theta ),\Sigma (\theta ))}$ is

${\displaystyle {\mathcal {I}}_{m,n}={\frac {\partial \mu }{\partial \theta _{m}}}\Sigma ^{-1}{\frac {\partial \mu ^{\top }}{\partial \theta _{n}}}+{\frac {1}{2}}\mathrm {tr} \left(\Sigma ^{-1}{\frac {\partial \Sigma }{\partial \theta _{m}}}\Sigma ^{-1}{\frac {\partial \Sigma }{\partial \theta _{n}}}\right)}$

where

• ${\displaystyle {\frac {\partial \mu }{\partial \theta _{m}}}={\begin{bmatrix}{\frac {\partial \mu _{1}}{\partial \theta _{m}}}&{\frac {\partial \mu _{2}}{\partial \theta _{m}}}&\cdots &{\frac {\partial \mu _{N}}{\partial \theta _{m}}}&\end{bmatrix}}}$
• ${\displaystyle {\frac {\partial \mu ^{\top }}{\partial \theta _{m}}}=\left({\frac {\partial \mu }{\partial \theta _{m}}}\right)^{\top }={\begin{bmatrix}{\frac {\partial \mu _{1}}{\partial \theta _{m}}}\\\\{\frac {\partial \mu _{2}}{\partial \theta _{m}}}\\\\\vdots \\\\{\frac {\partial \mu _{N}}{\partial \theta _{m}}}\\\\\end{bmatrix}}}$
• ${\displaystyle {\frac {\partial \Sigma }{\partial \theta _{m}}}={\begin{bmatrix}{\frac {\partial \Sigma _{1,1}}{\partial \theta _{m}}}&{\frac {\partial \Sigma _{1,2}}{\partial \theta _{m}}}&\cdots &{\frac {\partial \Sigma _{1,N}}{\partial \theta _{m}}}\\\\{\frac {\partial \Sigma _{2,1}}{\partial \theta _{m}}}&{\frac {\partial \Sigma _{2,2}}{\partial \theta _{m}}}&\cdots &{\frac {\partial \Sigma _{2,N}}{\partial \theta _{m}}}\\\\\vdots &\vdots &\ddots &\vdots \\\\{\frac {\partial \Sigma _{N,1}}{\partial \theta _{m}}}&{\frac {\partial \Sigma _{N,2}}{\partial \theta _{m}}}&\cdots &{\frac {\partial \Sigma _{N,N}}{\partial \theta _{m}}}\end{bmatrix}}}$
• ${\displaystyle \mathrm {tr} }$ is the trace function

## Kullback-Leibler divergence

The Kullback-Leibler divergence from ${\displaystyle N0_{N}(\mu _{0},\Sigma _{0})}$ to ${\displaystyle N1_{N}(\mu _{1},\Sigma _{1})}$ is:

${\displaystyle D_{\text{KL}}(N0\|N1)={1 \over 2}\left(\log _{e}\left({\det \Sigma _{1} \over \det \Sigma _{0}}\right)+\mathrm {tr} \left(\Sigma _{1}^{-1}\Sigma _{0}\right)+\left(\mu _{1}-\mu _{0}\right)^{\top }\Sigma _{1}^{-1}(\mu _{1}-\mu _{0})-N\right).}$

## Estimation of parameters

The derivation of the maximum-likelihood estimator of the covariance matrix of a multivariate normal distribution is perhaps surprisingly subtle and elegant. See estimation of covariance matrices.

In short, the probability density function (pdf) of an N-dimensional multivariate normal is

${\displaystyle f(x)=(2\pi )^{-N/2}\det(\Sigma )^{-1/2}\exp \left(-{1 \over 2}(x-\mu )^{T}\Sigma ^{-1}(x-\mu )\right)}$

and the ML estimator of the covariance matrix is

${\displaystyle {\widehat {\Sigma }}={1 \over n}\sum _{i=1}^{n}(X_{i}-{\overline {X}})(X_{i}-{\overline {X}})^{T}}$

which is simply the sample covariance matrix for sample size n. This is a biased estimator whose expectation is

${\displaystyle E[{\widehat {\Sigma }}]={n-1 \over n}\Sigma .}$

An unbiased sample covariance is

${\displaystyle {\widehat {\Sigma }}={1 \over n-1}\sum _{i=1}^{n}(X_{i}-{\overline {X}})(X_{i}-{\overline {X}})^{T}.}$

## Entropy

The differential entropy of the multivariate normal distribution is [2]

${\displaystyle h\left(f\right)=-\int _{-\infty }^{\infty }\int _{-\infty }^{\infty }\cdots \int _{-\infty }^{\infty }f(x)\ln f(x)\,dx}$
${\displaystyle ={\frac {1}{2}}\left(N+N\ln \left(2\pi \right)+\ln \left|\Sigma \right|\right)\!}$
${\displaystyle ={\frac {1}{2}}\ln\{(2\pi e)^{N}\left|\Sigma \right|\}}$

where ${\displaystyle \left|\Sigma \right|}$ is the determinant of the covariance matrix ${\displaystyle \Sigma }$.

## Multivariate normality tests

Multivariate normality tests check a given set of data for similarity to the multivariate normal distribution. The null hypothesis is that the data set is similar to the normal distribution, therefore a sufficiently small p-value indicates non-normal data. Multivariate normality tests include the Cox-Small test [3] and Smith and Jain's adaptation [4] of the Friedman-Rafsky test.

## Drawing values from the distribution

A widely used method for drawing a random vector ${\displaystyle X}$ from the ${\displaystyle N}$-dimensional multivariate normal distribution with mean vector ${\displaystyle \mu }$ and covariance matrix ${\displaystyle \Sigma }$ (required to be symmetric and positive-definite) works as follows:

1. Compute the Cholesky decomposition (matrix square root) of ${\displaystyle \Sigma }$, that is, find the unique lower triangular matrix ${\displaystyle A}$ such that ${\displaystyle A\,A^{T}=\Sigma }$.
2. Let ${\displaystyle Z=(z_{1},\dots ,z_{N})^{T}}$ be a vector whose components are ${\displaystyle N}$ independent standard normal variates (which can be generated, for example, by using the Box-Muller transform).
3. Let ${\displaystyle X}$ be ${\displaystyle \mu +A\,Z}$.

## References

1. Nikolaus Hansen. "The CMA Evolution Strategy: A Tutorial" (PDF).
2. Gokhale, DV (1989). "Entropy Expressions and Their Estimators for Multivariate Distributions". Information Theory, IEEE Transactions on. 35 (3): 688–692. Unknown parameter |coauthors= ignored (help); Unknown parameter |month= ignored (help)
3. Cox, D. R. (1978). "Testing multivariate normality". Biometrika. 65 (2): 263–272. Unknown parameter |coauthors= ignored (help); Unknown parameter |month= ignored (help)
4. Smith, Stephen P. (1988). "A test to determine the multivariate normality of a dataset". IEEE Transactions on Pattern Analysis and Machine Intelligence. 10 (5): 757–761. doi:10.1109/34.6789. Unknown parameter |coauthors= ignored (help); Unknown parameter |month= ignored (help)