Covariance
   HOME

TheInfoList



OR:

In probability theory and statistics, covariance is a measure of the joint variability of two random variables. If the greater values of one variable mainly correspond with the greater values of the other variable, and the same holds for the lesser values (that is, the variables tend to show similar behavior), the covariance is positive. In the opposite case, when the greater values of one variable mainly correspond to the lesser values of the other, (that is, the variables tend to show opposite behavior), the covariance is negative. The sign of the covariance therefore shows the tendency in the linear relationship between the variables. The magnitude of the covariance is not easy to interpret because it is not normalized and hence depends on the magnitudes of the variables. The normalized version of the covariance, the
correlation coefficient A correlation coefficient is a numerical measure of some type of correlation, meaning a statistical relationship between two variables. The variables may be two columns of a given data set of observations, often called a sample, or two components ...
, however, shows by its magnitude the strength of the linear relation. A distinction must be made between (1) the covariance of two random variables, which is a population
parameter A parameter (), generally, is any characteristic that can help in defining or classifying a particular system (meaning an event, project, object, situation, etc.). That is, a parameter is an element of a system that is useful, or critical, when ...
that can be seen as a property of the joint probability distribution, and (2) the sample covariance, which in addition to serving as a descriptor of the sample, also serves as an estimated value of the population parameter.


Definition

For two jointly distributed
real Real may refer to: Currencies * Brazilian real (R$) * Central American Republic real * Mexican real * Portuguese real * Spanish real * Spanish colonial real Music Albums * ''Real'' (L'Arc-en-Ciel album) (2000) * ''Real'' (Bright album) (2010) ...
-valued random variables X and Y with finite second moments, the covariance is defined as the expected value (or mean) of the product of their deviations from their individual expected values: \operatorname(X, Y) = \operatorname where \operatorname /math> is the expected value of X, also known as the mean of X. The covariance is also sometimes denoted \sigma_ or \sigma(X,Y), in analogy to variance. By using the linearity property of expectations, this can be simplified to the expected value of their product minus the product of their expected values: : \begin \operatorname(X, Y) &= \operatorname\left left(X_-_\operatorname\left[X\rightright)_\left(Y_-_\operatorname\left[Y\right.html" ;"title="\right.html" ;"title="left(X - \operatorname\left[X\right">left(X - \operatorname\left[X\rightright) \left(Y - \operatorname\left[Y\right">\right.html" ;"title="left(X - \operatorname\left[X\right">left(X - \operatorname\left[X\rightright) \left(Y - \operatorname\left[Y\rightright)\right] \\ &= \operatorname\left[X Y - X \operatorname\left \right- \operatorname\left \rightY + \operatorname\left \right\operatorname\left \rightright] \\ &= \operatorname\left Y\right- \operatorname\left \right\operatorname\left \right- \operatorname\left \right\operatorname\left \right+ \operatorname\left \right\operatorname\left \right\\ &= \operatorname\left Y\right- \operatorname\left \right\operatorname\left \right \end but this equation is susceptible to catastrophic cancellation (see the section on
numerical computation Numerical analysis is the study of algorithms that use numerical approximation (as opposed to symbolic manipulations) for the problems of mathematical analysis (as distinguished from discrete mathematics). It is the study of numerical methods th ...
below). The
units of measurement A unit of measurement is a definite magnitude of a quantity, defined and adopted by convention or by law, that is used as a standard for measurement of the same kind of quantity. Any other quantity of that kind can be expressed as a multi ...
of the covariance \operatorname(X, Y) are those of X times those of Y. By contrast, correlation coefficients, which depend on the covariance, are a
dimensionless A dimensionless quantity (also known as a bare quantity, pure quantity, or scalar quantity as well as quantity of dimension one) is a quantity to which no physical dimension is assigned, with a corresponding SI unit of measurement of one (or 1) ...
measure of linear dependence. (In fact, correlation coefficients can simply be understood as a normalized version of covariance.)


Definition for complex random variables

The covariance between two
complex random variable In probability theory and statistics, complex random variables are a generalization of real-valued random variables to complex numbers, i.e. the possible values a complex random variable may take are complex numbers. Complex random variables can alw ...
s Z, W is defined as :\operatorname(Z, W) = \operatorname\left Z_-_\operatorname[Z\overline\right.html" ;"title=".html" ;"title="Z - \operatorname[Z">Z - \operatorname[Z\overline\right">.html" ;"title="Z - \operatorname[Z">Z - \operatorname[Z\overline\right= \operatorname\left[Z\overline\right] - \operatorname[Z]\operatorname\left[\overline\right] Notice the complex conjugation of the second factor in the definition. A related ''pseudo-covariance'' can also be defined.


Discrete random variables

If the (real) random variable pair (X,Y) can take on the values (x_i,y_i) for i=1,\ldots,n, with equal probabilities p_i=1/n, then the covariance can be equivalently written in terms of the means \operatorname /math> and \operatorname /math> as :\operatorname (X,Y)=\frac\sum_^n (x_i-E(X))(y_i-E(Y)). It can also be equivalently expressed, without directly referring to the means, as : \operatorname(X,Y) = \frac \sum_^n \sum_^n \frac(x_i - x_j)(y_i - y_j) = \frac \sum_i \sum_ (x_i-x_j)(y_i - y_j). More generally, if there are n possible realizations of (X,Y), namely (x_i,y_i) but with possibly unequal probabilities p_i for i=1,\ldots,n, then the covariance is :\operatorname (X,Y)=\sum_^n p_i (x_i-E(X)) (y_i-E(Y)).


Example

Suppose that X and Y have the following
joint probability mass function Given two random variables that are defined on the same probability space, the joint probability distribution is the corresponding probability distribution on all possible pairs of outputs. The joint distribution can just as well be considered ...
, in which the six central cells give the discrete joint probabilities f(x, y) of the six hypothetical realizations (x, y) \in S = \left\: X can take on three values (5, 6 and 7) while Y can take on two (8 and 9). Their means are \mu_X = 5(0.3) + 6(0.4) + 7(0.1 + 0.2) = 6 and \mu_Y = 8(0.4 + 0.1) + 9(0.3 + 0.2) = 8.5. Then, :\begin \operatorname(X, Y) = &\sigma_ = \sum_f(x, y) \left(x - \mu_X\right)\left(y - \mu_Y\right) \\ pt = &(0)(5 - 6)(8 - 8.5) + (0.4)(6 - 6)(8 - 8.5) + (0.1)(7 - 6)(8 - 8.5) + \\ pt &(0.3)(5 - 6)(9 - 8.5) + (0)(6 - 6)(9 - 8.5) + (0.2)(7 - 6)(9 - 8.5) \\ pt = & \; . \end


Properties


Covariance with itself

The variance is a special case of the covariance in which the two variables are identical (that is, in which one variable always takes the same value as the other): :\operatorname(X, X) =\operatorname(X)\equiv\sigma^2(X)\equiv\sigma_X^2.


Covariance of linear combinations

If X, Y, W, and V are real-valued random variables and a,b,c,d are real-valued constants, then the following facts are a consequence of the definition of covariance: : \begin \operatorname(X, a) &= 0 \\ \operatorname(X, X) &= \operatorname(X) \\ \operatorname(X, Y) &= \operatorname(Y, X) \\ \operatorname(aX, bY) &= ab\, \operatorname(X, Y) \\ \operatorname(X+a, Y+b) &= \operatorname(X, Y) \\ \operatorname(aX+bY, cW+dV) &= ac\,\operatorname(X,W)+ad\,\operatorname(X,V)+bc\,\operatorname(Y,W)+bd\,\operatorname(Y,V) \end For a sequence X_1,\ldots,X_n of random variables in real-valued, and constants a_1,\ldots,a_n, we have :\operatorname\left(\sum_^n a_iX_i \right) = \sum_^n a_i^2\sigma^2(X_i) + 2\sum_ a_ia_j\operatorname(X_i,X_j) = \sum_


Hoeffding's covariance identity

A useful identity to compute the covariance between two random variables X, Y is the Hoeffding's covariance identity: :\operatorname(X, Y) = \int_\mathbb R \int_\mathbb R \left(F_(x, y) - F_X(x)F_Y(y)\right) \,dx \,dy where F_(x,y) is the joint cumulative distribution function of the random vector (X, Y) and F_X(x), F_Y(y) are the marginals.


Uncorrelatedness and independence

Random variables whose covariance is zero are called uncorrelated. Similarly, the components of random vectors whose covariance matrix is zero in every entry outside the main diagonal are also called uncorrelated. If X and Y are
independent random variables Independent or Independents may refer to: Arts, entertainment, and media Artist groups * Independents (artist group), a group of modernist painters based in the New Hope, Pennsylvania, area of the United States during the early 1930s * Independe ...
, then their covariance is zero. This follows because under independence, : \operatorname Y\operatorname \cdot \operatorname The converse, however, is not generally true. For example, let X be uniformly distributed in 1,1/math> and let Y=X^2. Clearly, X and Y are not independent, but : \begin \operatorname(X, Y) &= \operatorname\left(X, X^2\right) \\ &= \operatorname\left \cdot X^2\right- \operatorname \cdot \operatorname\left ^2\right\\ &= \operatorname\left ^3\right- \operatorname operatorname\left ^2\right\\ &= 0 - 0 \cdot \operatorname ^2\\ &= 0. \end In this case, the relationship between Y and X is non-linear, while correlation and covariance are measures of linear dependence between two random variables. This example shows that if two random variables are uncorrelated, that does not in general imply that they are independent. However, if two variables are jointly normally distributed (but not if they are merely individually normally distributed), uncorrelatedness ''does'' imply independence.


Relationship to inner products

Many of the properties of covariance can be extracted elegantly by observing that it satisfies similar properties to those of an
inner product In mathematics, an inner product space (or, rarely, a Hausdorff pre-Hilbert space) is a real vector space or a complex vector space with an operation called an inner product. The inner product of two vectors in the space is a scalar, often ...
: # bilinear: for constants a and b and random variables X,Y,Z, \operatorname(aX+bY,Z) = a \operatorname(X,Z) + b \operatorname(Y,Z) # symmetric: \operatorname(X,Y) = \operatorname(Y,X) # positive semi-definite: \sigma^2(X) = \operatorname(X,X) \ge 0 for all random variables X, and \operatorname(X,X) = 0 implies that X is constant almost surely. In fact these properties imply that the covariance defines an inner product over the
quotient vector space In linear algebra, the quotient of a vector space ''V'' by a subspace ''N'' is a vector space obtained by "collapsing" ''N'' to zero. The space obtained is called a quotient space and is denoted ''V''/''N'' (read "''V'' mod ''N''" or "''V'' by ' ...
obtained by taking the subspace of random variables with finite second moment and identifying any two that differ by a constant. (This identification turns the positive semi-definiteness above into positive definiteness.) That quotient vector space is isomorphic to the subspace of random variables with finite second moment and mean zero; on that subspace, the covariance is exactly the L2 inner product of real-valued functions on the sample space. As a result, for random variables with finite variance, the inequality : , \operatorname(X, Y), \le \sqrt holds via the Cauchy–Schwarz inequality. Proof: If \sigma^2(Y) = 0, then it holds trivially. Otherwise, let random variable : Z = X - \frac Y. Then we have : \begin 0 \le \sigma^2(Z) &= \operatorname\left( X - \frac Y,\; X - \frac Y \right) \\ 2pt &= \sigma^2(X) - \frac. \end


Calculating the sample covariance

The sample covariances among K variables based on N observations of each, drawn from an otherwise unobserved population, are given by the K \times K matrix \textstyle \overline = \left _\right/math> with the entries :q_ = \frac\sum_^N \left(X_ - \bar_j\right) \left(X_ - \bar_k\right), which is an estimate of the covariance between variable j and variable k. The sample mean and the sample covariance matrix are unbiased estimates of the mean and the covariance matrix of the
random vector In probability, and statistics, a multivariate random variable or random vector is a list of mathematical variables each of whose value is unknown, either because the value has not yet occurred or because there is imperfect knowledge of its value ...
\textstyle \mathbf, a vector whose ''j''th element (j = 1,\, \ldots,\, K) is one of the random variables. The reason the sample covariance matrix has \textstyle N-1 in the denominator rather than \textstyle N is essentially that the population mean \operatorname(\mathbf) is not known and is replaced by the sample mean \mathbf. If the population mean \operatorname(\mathbf) is known, the analogous unbiased estimate is given by : q_ = \frac \sum_^N \left(X_ - \operatorname\left(X_j\right)\right) \left(X_ - \operatorname\left(X_k\right)\right).


Generalizations


Auto-covariance matrix of real random vectors

For a vector \mathbf = \beginX_1 & X_2 & \dots & X_m\end^\mathrm of m jointly distributed random variables with finite second moments, its auto-covariance matrix (also known as the variance–covariance matrix or simply the covariance matrix) \operatorname_ (also denoted by \Sigma(\mathbf) or \operatorname(\mathbf, \mathbf)) is defined as :\begin \operatorname_\mathbf = \operatorname(\mathbf, \mathbf) &= \operatorname\left \mathbf_-_\operatorname[\mathbf_(\mathbf_-_\operatorname[\mathbf.html" ;"title="mathbf.html" ;"title="\mathbf - \operatorname[\mathbf">\mathbf - \operatorname[\mathbf (\mathbf - \operatorname[\mathbf">mathbf.html" ;"title="\mathbf - \operatorname[\mathbf">\mathbf - \operatorname[\mathbf (\mathbf - \operatorname[\mathbf^\mathrm\right] \\ &= \operatorname\left mathbf^\mathrm\right- \operatorname[\mathbf]\operatorname[\mathbf]^\mathrm. \end Let \mathbf be a
random vector In probability, and statistics, a multivariate random variable or random vector is a list of mathematical variables each of whose value is unknown, either because the value has not yet occurred or because there is imperfect knowledge of its value ...
with covariance matrix , and let be a matrix that can act on \mathbf on the left. The covariance matrix of the matrix-vector product is: :\begin \operatorname(\mathbf,\mathbf) &= \operatorname\left mathbf\mathbf^\mathrm\right- \operatorname mathbf\operatorname\left \mathbf\mathbf)^\mathrm\right\\ &= \operatorname\left mathbf^\mathrm\mathbf^\mathrm\right- \operatorname mathbf\operatorname\left mathbf^\mathrm\mathbf^\mathrm\right\\ &= \mathbf\operatorname\left mathbf^\mathrm\rightmathbf^\mathrm - \mathbf\operatorname mathbf\operatorname\left mathbf^\mathrm\rightmathbf^\mathrm \\ &= \mathbf\left(\operatorname\left mathbf^\mathrm\right- \operatorname mathbf\operatorname\left mathbf^\mathrm\rightright)\mathbf^\mathrm \\ &= \mathbf\Sigma\mathbf^\mathrm. \end This is a direct result of the linearity of expectation and is useful when applying a
linear transformation In mathematics, and more specifically in linear algebra, a linear map (also called a linear mapping, linear transformation, vector space homomorphism, or in some contexts linear function) is a mapping V \to W between two vector spaces that pre ...
, such as a whitening transformation, to a vector.


Cross-covariance matrix of real random vectors

For real
random vector In probability, and statistics, a multivariate random variable or random vector is a list of mathematical variables each of whose value is unknown, either because the value has not yet occurred or because there is imperfect knowledge of its value ...
s \mathbf \in \mathbb^m and \mathbf \in \mathbb^n, the m \times n cross-covariance matrix is equal to where \mathbf^ is the
transpose In linear algebra, the transpose of a matrix is an operator which flips a matrix over its diagonal; that is, it switches the row and column indices of the matrix by producing another matrix, often denoted by (among other notations). The tr ...
of the vector (or matrix) \mathbf. The (i,j)-th element of this matrix is equal to the covariance \operatorname(X_i,Y_j) between the -th scalar component of \mathbf and the -th scalar component of \mathbf. In particular, \operatorname(\mathbf,\mathbf) is the
transpose In linear algebra, the transpose of a matrix is an operator which flips a matrix over its diagonal; that is, it switches the row and column indices of the matrix by producing another matrix, often denoted by (among other notations). The tr ...
of \operatorname(\mathbf,\mathbf).


Cross-covariance sesquilinear form of random vectors in a real or complex Hilbert space

More generally let H_1 = (H_1, \langle \,,\rangle_1) and H_2 = (H_2, \langle \,,\rangle_2), be Hilbert spaces over \mathbb or \mathbb with \langle \,, \rangle anti linear in the first variable, and let \mathbf, \mathbf be H_1 resp. H_2 valued random variables. Then the covariance of \mathbf and \mathbf is the sesquilinear form on H_1 \times H_2 (anti linear in the first variable) given by :\begin \operatorname_(h_1,h_2) = \operatorname(\mathbf,\mathbf)(h_1,h_2) &= \operatorname\left langle_h_1,(\mathbf_-_\operatorname[\mathbf\rangle_1\langle(\mathbf_-_\operatorname[\mathbf.html" ;"title="mathbf.html" ;"title="langle h_1,(\mathbf - \operatorname[\mathbf">langle h_1,(\mathbf - \operatorname[\mathbf\rangle_1\langle(\mathbf - \operatorname[\mathbf">mathbf.html" ;"title="langle h_1,(\mathbf - \operatorname[\mathbf">langle h_1,(\mathbf - \operatorname[\mathbf\rangle_1\langle(\mathbf - \operatorname[\mathbf, h_2 \rangle_2\right]\\ &= \operatorname[\langle h_1,\mathbf\rangle_1\langle\mathbf, h_2 \rangle_2] - \operatorname[\langle h,\mathbf \rangle_1]\operatorname[\langle \mathbf,h_2 \rangle_2] \\ &= \langle h_1, \operatorname\left \mathbf_-_\operatorname[\mathbf(\mathbf_-_\operatorname[\mathbf.html" ;"title="mathbf.html" ;"title="\mathbf - \operatorname[\mathbf">\mathbf - \operatorname[\mathbf(\mathbf - \operatorname[\mathbf">mathbf.html" ;"title="\mathbf - \operatorname[\mathbf">\mathbf - \operatorname[\mathbf(\mathbf - \operatorname[\mathbf^\dagger \right]h_2 \rangle_1\\ &= \langle h_1, \left( \operatorname[\mathbf\mathbf^\dagger] - \operatorname[\mathbf]\operatorname[\mathbf]^\dagger \right) h_2 \rangle_1\\ \end


Numerical computation

When \operatorname Y\approx \operatorname operatorname /math>, the equation \operatorname(X, Y) = \operatorname\left Y\right- \operatorname\left \right\operatorname\left \right/math> is prone to catastrophic cancellation if \operatorname\left Y\right/math> and \operatorname\left \right\operatorname\left \right/math> are not computed exactly and thus should be avoided in computer programs when the data has not been centered before. Numerically stable algorithms should be preferred in this case.


Comments

The covariance is sometimes called a measure of "linear dependence" between the two random variables. That does not mean the same thing as in the context of linear algebra (see linear dependence). When the covariance is normalized, one obtains the
Pearson correlation coefficient In statistics, the Pearson correlation coefficient (PCC, pronounced ) ― also known as Pearson's ''r'', the Pearson product-moment correlation coefficient (PPMCC), the bivariate correlation, or colloquially simply as the correlation coefficient ...
, which gives the goodness of the fit for the best possible linear function describing the relation between the variables. In this sense covariance is a linear gauge of dependence.


Applications


In genetics and molecular biology

Covariance is an important measure in
biology Biology is the scientific study of life. It is a natural science with a broad scope but has several unifying themes that tie it together as a single, coherent field. For instance, all organisms are made up of cells that process hereditary i ...
. Certain sequences of DNA are conserved more than others among species, and thus to study secondary and tertiary structures of
protein Proteins are large biomolecules and macromolecules that comprise one or more long chains of amino acid residues. Proteins perform a vast array of functions within organisms, including catalysing metabolic reactions, DNA replication, res ...
s, or of RNA structures, sequences are compared in closely related species. If sequence changes are found or no changes at all are found in noncoding RNA (such as
microRNA MicroRNA (miRNA) are small, single-stranded, non-coding RNA molecules containing 21 to 23 nucleotides. Found in plants, animals and some viruses, miRNAs are involved in RNA silencing and post-transcriptional regulation of gene expression. mi ...
), sequences are found to be necessary for common structural motifs, such as an RNA loop. In genetics, covariance serves a basis for computation of Genetic Relationship Matrix (GRM) (aka kinship matrix), enabling inference on population structure from sample with no known close relatives as well as inference on estimation of heritability of complex traits. In the theory of
evolution Evolution is change in the heritable characteristics of biological populations over successive generations. These characteristics are the expressions of genes, which are passed on from parent to offspring during reproduction. Variation ...
and
natural selection Natural selection is the differential survival and reproduction of individuals due to differences in phenotype. It is a key mechanism of evolution, the change in the heritable traits characteristic of a population over generations. Cha ...
, the Price equation describes how a genetic trait changes in frequency over time. The equation uses a covariance between a trait and fitness, to give a mathematical description of evolution and natural selection. It provides a way to understand the effects that gene transmission and natural selection have on the proportion of genes within each new generation of a population. The Price equation was derived by George R. Price, to re-derive W.D. Hamilton's work on kin selection. Examples of the Price equation have been constructed for various evolutionary cases.


In financial economics

Covariances play a key role in financial economics, especially in
modern portfolio theory Modern portfolio theory (MPT), or mean-variance analysis, is a mathematical framework for assembling a portfolio of assets such that the expected return is maximized for a given level of risk. It is a formalization and extension of diversificati ...
and in the capital asset pricing model. Covariances among various assets' returns are 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.


In meteorological and oceanographic data assimilation

The covariance matrix is important in estimating the initial conditions required for running weather forecast models, a procedure known as data assimilation. The 'forecast error covariance matrix' is typically constructed between perturbations around a mean state (either a climatological or ensemble mean). The 'observation error covariance matrix' is constructed to represent the magnitude of combined observational errors (on the diagonal) and the correlated errors between measurements (off the diagonal). This is an example of its widespread application to Kalman filtering and more general
state estimation In control theory, a state observer or state estimator is a system that provides an estimate of the internal state of a given real system, from measurements of the input and output of the real system. It is typically computer-implemented, and pro ...
for time-varying systems.


In micrometeorology

The
eddy covariance The eddy covariance (also known as eddy correlation and eddy flux) is a key atmospheric measurement technique to measure and calculate vertical turbulent fluxes within atmospheric boundary layers. The method analyses high-frequency wind and scal ...
technique is a key atmospherics measurement technique where the covariance between instantaneous deviation in vertical wind speed from the mean value and instantaneous deviation in gas concentration is the basis for calculating the vertical turbulent fluxes.


In signal processing

The covariance matrix is used to capture the spectral variability of a signal.


In statistics and image processing

The covariance matrix is used in principal component analysis to reduce feature dimensionality in
data preprocessing Data preprocessing can refer to manipulation or dropping of data before it is used in order to ensure or enhance performance, and is an important step in the data mining process. The phrase "garbage in, garbage out" is particularly applicable to ...
.


See also

* Algorithms for calculating covariance * Analysis of covariance *
Autocovariance In probability theory and statistics, given a stochastic process, the autocovariance is a function that gives the covariance of the process with itself at pairs of time points. Autocovariance is closely related to the autocorrelation of the process ...
* Covariance function * Covariance operator * Distance covariance, or Brownian covariance. * Law of total covariance *
Propagation of uncertainty In statistics, propagation of uncertainty (or propagation of error) is the effect of variables' uncertainties (or errors, more specifically random errors) on the uncertainty of a function based on them. When the variables are the values of exp ...


References

{{statistics Covariance and correlation Algebra of random variables