# Covariance matrix

In statistics and probability theory, the covariance matrix is a matrix of covariances between elements of a vector. It is the natural generalization to higher dimensions, of the concept of the variance of a scalar-valued random variable.

If [itex]X[itex] is a column vector with [itex]n[itex] scalar random variable components, and [itex]\mu_k[itex] is the expected value of the kth element of [itex]X[itex], i.e. [itex]\mu_k = \mathrm{E}(X_k)[itex], then the covariance matrix is defined as:

[itex]

\Sigma=\mathrm{E} \left[

\left(
\textbf{X} - \mathrm{E}[\textbf{X}]
\right)
\left(
\textbf{X} - \mathrm{E}[\textbf{X}]
\right)^\top


\right] [itex]

[itex]

= \begin{bmatrix}

\mathrm{E}[(X_1 - \mu_1)(X_1 - \mu_1)], & \mathrm{E}[(X_1 - \mu_1)(X_2 - \mu_2)], & \cdots & \mathrm{E}[(X_1 - \mu_1)(X_n - \mu_n)] \\  \\
\mathrm{E}[(X_2 - \mu_2)(X_1 - \mu_1)], & \mathrm{E}[(X_2 - \mu_2)(X_2 - \mu_2)], & \cdots & \mathrm{E}[(X_2 - \mu_2)(X_n - \mu_n)] \\  \\
\vdots & \vdots & \ddots & \vdots \\  \\
\mathrm{E}[(X_n - \mu_n)(X_1 - \mu_1)], & \mathrm{E}[(X_n - \mu_n)(X_2 - \mu_2)], & \cdots & \mathrm{E}[(X_n - \mu_n)(X_n - \mu_n)]


\end{bmatrix} [itex]

The [itex](i,j)[itex] element is the covariance between [itex]X_i[itex] and [itex]X_j[itex].

This concept generalizes to higher dimensions the concept of variance of a scalar-valued random variable [itex]X[itex], defined as

[itex]

\sigma^2 = \mathrm{var}(X) = \mathrm{E}[(X-\mu)^2] \, [itex]

where [itex]\mu = \mathrm{E}(X)[itex].

 Contents

## Conflicting nomenclatures and notations

Nomenclatures differ. Some statisticians, following the probabilist William Feller, call this matrix the variance of the random vector [itex]X[itex], because it is the natural generalization to higher dimensions of the 1-dimensional variance. Others call it the covariance matrix, because it is the matrix of covariances between the scalar components of the vector [itex]X[itex]. Unfortunately, several different conventions jar to some degree with each other:

Standard notation:

[itex]

\operatorname{var}(\textbf{X}) = \mathrm{E} \left[

(\textbf{X} - \mathrm{E} [\textbf{X}])
(\textbf{X} - \mathrm{E} [\textbf{X}])^\top


\right] [itex]

Also standard notation (unfortunately conflicting with the above):

[itex]

\operatorname{cov}(\textbf{X}) = \mathrm{E} \left[

(\textbf{X} - \mathrm{E}[\textbf{X}])
(\textbf{X} - \mathrm{E}[\textbf{X}])^\top


\right] [itex]

Also standard notation:

[itex]

\operatorname{cov}(\textbf{X},\textbf{Y}) = \mathrm{E} \left[

(\textbf{X} - \mathrm{E}[\textbf{X}])
(\textbf{Y} - \mathrm{E}[\textbf{Y}])^\top


\right] [itex] (the "cross-covariance" between two random vectors)

The first two of these usages conflict with each other. The first and third are in perfect harmony. The first notation is found in William Feller's universally admired two-volume book on probability.

## Properties

With scalar-valued random variables [itex]X[itex], we have the identity

[itex]\mathrm{var}(a X) = a^2 \mathrm{var}(X)[itex]

if [itex]a[itex] is constant, i.e., not random. If [itex]X[itex] is an [itex]n \times 1[itex] column vector-valued random variable and [itex]A[itex] is an [itex]m \times n[itex] constant (i.e., non-random) matrix, then [itex]A x[itex] is an [itex]m \times 1[itex] column vector-valued random variable, whose variance must therefore be an [itex]m \times m[itex] matrix. It is

[itex]

\operatorname{var} (A \textbf{X}) = A \Sigma A^\top. [itex]

For cross-covariance matrices we have

[itex]\operatorname{cov}(AX,BY)=A(\operatorname{cov}(X,Y))B^\top. \,[itex]

This covariance matrix (though very simple) is a very useful tool in many very different areas. From it a transformation matrix can be derived that allows one to completely decorrelate the data or, from a different point of view, to find an optimal basis for representing the data in a compact way. This is called principal components analysis (PCA) in statistics and Karhunen-Loève transform (KL-transform) in image processing.

## Complex random vectors

The variance of a complex scalar-valued random variable with expected value μ is conventionally defined using complex conjugation:

[itex]

\operatorname{var}(z) = \operatorname{E} \left[

(z-\mu)(z-\mu)^{*}


\right] [itex]

where the complex conjugate of a complex number [itex]z[itex] is denoted [itex]z^{*}[itex].

If [itex]Z[itex] is a column-vector of complex-valued random variables, then we take the conjugate transpose by both transposing and conjugating, getting a square matrix:

[itex]

\operatorname{E} \left[

(Z-\mu)(Z-\mu)^{*}


\right] [itex]

where [itex]Z^{*}[itex] denotes the conjugate transpose, which is applicable to the scalar case since the transpose of a scalar is still a scalar.

## Estimation

The derivation of the maximum-likelihood estimator of the covariance matrix of a multivariate normal distribution is perhaps surprisingly subtle. It involves the spectral theorem and the reason why it can be better to view a scalar as the trace of a [itex]1 \times 1[itex] matrix than as a mere scalar. See estimation of covariance matrices.

## External references

• Covariance Matrix (http://mathworld.wolfram.com/CovarianceMatrix.html) at Mathworld

• Art and Cultures
• Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
• Space and Astronomy