In probability theory and statistics, a covariance matrix (also known as dispersion matrix or variance–covariance matrix) is a matrix whose element in the i, j position is the covariance between the i ^{th} and j ^{th} elements of a random vector. A random vector is a random variable with multiple dimensions. Each element of the vector is a scalar random variable. Each element has either a finite number of observed empirical values or a finite or infinite number of potential values. The potential values are specified by a theoretical joint probability distribution.
Contents
 Definition
 Generalization of the variance
 Correlation matrix
 Conflicting nomenclatures and notations
 Properties
 Block matrices
 As a parameter of a distribution
 As a linear operator
 Complex random vectors
 Estimation
 Applications
 References
Intuitively, the covariance matrix generalizes the notion of variance to multiple dimensions. As an example, the variation in a collection of random points in twodimensional space cannot be characterized fully by a single number, nor would the variances in the x and y directions contain all of the necessary information; a 2×2 matrix would be necessary to fully characterize the twodimensional variation.
Because the covariance of the i^{th} random variable with itself is simply that random variable's variance, each element on the principal diagonal of the covariance matrix is the variance of one of the random variables. Because the covariance of the i^{th} random variable with the j^{th} one is the same thing as the covariance of the j^{th} random variable with the i^{th} one, every covariance matrix is symmetric. In addition, every covariance matrix is positive semidefinite.
Definition
Throughout this article, boldfaced unsubscripted X and Y are used to refer to random vectors, and unboldfaced subscripted X_{i} and Y_{i} are used to refer to random scalars.
If the entries in the column vector
are random variables, each with finite variance, then the covariance matrix Σ is the matrix whose (i, j) entry is the covariance
where
is the expected value of the i th entry in the vector X. In other words,
The inverse of this matrix,
Generalization of the variance
The definition above is equivalent to the matrix equality
This form can be seen as a generalization of the scalarvalued variance to higher dimensions. Recall that for a scalarvalued random variable X
Indeed, the entries on the diagonal of the covariance matrix
Correlation matrix
A quantity closely related to the covariance matrix is the correlation matrix, the matrix of Pearson productmoment correlation coefficients between each of the random variables in the random vector
where
Equivalently, the correlation matrix can be seen as the covariance matrix of the standardized random variables
Each element on the principal diagonal of a correlation matrix is the correlation of a random variable with itself, which always equals 1. Each offdiagonal element is between 1 and –1 inclusive.
Conflicting nomenclatures and notations
Nomenclatures differ. Some statisticians, following the probabilist William Feller in his twovolume book An Introduction to Probability Theory and Its Applications, call the matrix
Both forms are quite standard and there is no ambiguity between them. The matrix
By comparison, the notation for the crosscovariance between two vectors is
Properties
For

Σ = E ( X X T ) − μ μ T 
Σ is positivesemidefinite and symmetric. 
var ( A X + a ) = A var ( X ) A T 
cov ( X , Y ) = cov ( Y , X ) T 
cov ( X 1 + X 2 , Y ) = cov ( X 1 , Y ) + cov ( X 2 , Y )  If p = q, then
var ( X + Y ) = var ( X ) + cov ( X , Y ) + cov ( Y , X ) + var ( Y ) 
cov ( A X + a , B T Y + b ) = A cov ( X , Y ) B  If
X andY are independent (or somewhat less restrictedly, if every random variable inX is uncorrelated with every random variable inY ), thencov ( X , Y ) = 0
where
This covariance matrix is a useful tool in many different areas. From it a transformation matrix can be derived, called a whitening transformation, 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 (see Rayleigh quotient for a formal proof and additional properties of covariance matrices). This is called principal components analysis (PCA) and the KarhunenLoève transform (KLtransform).
Block matrices
The joint mean
where
If
then the conditional distribution for
defined by conditional mean
and conditional variance
The matrix Σ_{YX}Σ_{XX}^{−1} is known as the matrix of regression coefficients, while in linear algebra Σ_{YX} is the Schur complement of Σ_{XX} in Σ_{X,Y}
The matrix of regression coefficients may often be given in transpose form, Σ_{XX}^{−1}Σ_{XY}, suitable for postmultiplying a row vector of explanatory variables x^{T} rather than premultiplying a column vector x. In this form they correspond to the coefficients obtained by inverting the matrix of the normal equations of ordinary least squares (OLS).
As a parameter of a distribution
If a vector of n possibly correlated random variables is jointly normally distributed, or more generally elliptically distributed, then its probability density function can be expressed in terms of the covariance matrix.
As a linear operator
Applied to one vector, the covariance matrix maps a linear combination, c, of the random variables, X, onto a vector of covariances with those variables:
Similarly, the (pseudo)inverse covariance matrix provides an inner product,
Complex random vectors
The variance of a complex scalarvalued random variable with expected value μ is conventionally defined using complex conjugation:
where the complex conjugate of a complex number
If
where
Estimation
If
or, if the column means were known apriori,
These empirical sample correlation matrices are the most straightforward and most often used estimators for the correlation matrices, but other estimators also exist, including regularised or shrinkage estimators, which may have better properties.
Applications
The covariance matrix plays a key role in financial economics, especially in portfolio theory and its mutual fund separation theorem and in the capital asset pricing model. The matrix of covariances among various assets' returns is used to determine, under certain assumptions, the relative amounts of different assets that investors should (in a normative analysis) or are predicted to (in a positive analysis) choose to hold in a context of diversification.