Multivariate Gaussian distribution (source code)

= Multivariate Gaussian distribution
{wiki}

A <multivariate Gaussian distribution> is the law of a <Random vector> $X\in\mathbb R^d$ such that every <linear combination> $a^TX$ has a <Normal distribution>, allowing a constant as a zero-variance <Normal distribution>. Its <Mean vector> $\mu$ and <positive semidefinite matrix>[positive-semidefinite] <covariance matrix> $\Sigma$ determine its <Characteristic function>:
$$
\mathbb E e^{it^TX}=\exp\left(it^T\mu-\tfrac12t^T\Sigma t\right).
$$
If $\Sigma$ is <positive-definite matrix>[positive definite], the law has the normalized <Probability density function>
$$
f(x)=\frac{\exp[-(x-\mu)^T\Sigma^{-1}(x-\mu)/2]}{(2\pi)^{d/2}\sqrt{\det\Sigma}}.
$$
A singular <covariance matrix> is also permitted, but this <probability density function>[density] formula is not: the law is concentrated on the <affine subspace> $\mu+\operatorname{range}\Sigma$. For example, $(Z,Z)$ with $Z$ <standard normal distribution>[standard normal] has <covariance> $\begin{pmatrix}1&1\\1&1\end{pmatrix}$ and lives on the diagonal, so it has no two-dimensional Lebesgue <probability density function>[density].

A construction valid in both cases is $X=\mu+AZ$, where $Z$ has <independent> <standard normal distribution>[standard normal] coordinates and $AA^T=\Sigma$. Its <Characteristic function> follows by multiplying the one-dimensional <characteristic functions>. For $\operatorname{rank}\Sigma=r$, one can use a <matrix> $A$ with $r$ columns.

Normal <marginal distribution>[marginals] alone do not imply a multivariate Gaussian law. Let $Z$ be <standard normal distribution>[standard normal] and let $S$ be an <independent> <Rademacher random variable>. Both $Z$ and $SZ$ are <standard normal distribution>[standard normal], but their sum is zero with <probability> $1/2$ and otherwise equals $2Z$, so that nonconstant sum is not normal. <multivariate Gaussian distribution>[Joint Gaussianity] is the stronger condition needed for Gaussian <moment> and linear-transformation rules.