# Covariance/Citable Version  Main Article Discussion Related Articles  [?] Bibliography  [?] External Links  [?] Citable Version  [?] This version approved either by the Approvals Committee, or an Editor from the listed workgroup. The Mathematics Workgroup is responsible for this citable version. While we have done conscientious work, we cannot guarantee that this version is wholly free of mistakes. See here (not History) for authorship. Help improve this work further on the editable Main Article!

The covariance — usually denoted as Cov — is a statistical parameter used to compare two real random variables on the same sample space (more precisely, the same probability space).
It is defined as the expectation (or mean value) of the product of the deviations (from their respective mean values) of the two variables.

The sign of the covariance indicates a linear trend between the two variables.

• If one variable increases (in the mean) with the other, then the covariance is positive.
• It is negative if one variable tends to decrease when the other increases.
• If it is 0 then there is no linear correlation between the two variables.
In particular, this is the case for stochastically independent variables. But the inverse is not true because there may still be other – nonlinear – dependencies.

The value of the covariance is scale-dependent and therefore does not show how strong the correlation is. For this purpose a normed version of the covariance is used — the correlation coefficient which is independent of scale.

## Formal definition

The covariance of two real random variables X and Y with expectation (mean value)

$\mathrm {E} (X)=\mu _{X}\quad {\text{and}}\quad \mathrm {E} (Y)=\mu _{Y}$ is defined by

$\operatorname {Cov} (X,Y):=\mathrm {E} ((X-\mu _{X})(Y-\mu _{Y}))=\mathrm {E} (XY)-\mathrm {E} (X)\mathrm {E} (Y)$ Remark:
If the two random variables are the same then their covariance is equal to the variance of the single variable: Cov(X,X) = Var(X).

In a more general context of probability theory the covariance is a second-order central moment of the two-dimensional random variable (X,Y), often denoted as μ11.

## Finite data

For a finite set of data

$(x_{i},y_{i})\in \mathbb {R} ^{2}\ {\text{with}}\ i=1,\dots ,n$ the covariance is given by

${1 \over n}\sum _{i=1}^{n}(x_{i}-{\overline {x}})(y_{i}-{\overline {y}})\qquad {\text{where}}\ {\overline {x}}:={1 \over n}\sum _{i=1}^{n}x_{i}\ {\text{and}}\ {\overline {y}}:={1 \over n}\sum _{i=1}^{n}y_{i}$ or, using a convenient notation

$[a_{i}]:=\sum _{i=1}^{n}a_{i}$ introduced by Gauss, by

${1 \over n}([x_{i}y_{i}]-[x_{i}][y_{i}])$ This is equivalent to taking the uniform distribution where each item (xi,yi) has probability 1/n.

## Unbiased estimate

The expectation of the covariance of a random sample — taken from a probability distribution — depends on the size n of the sample and is slightly smaller than the covariance of the distribution.

An unbiased estimate of the covariance is

$\mathrm {Cov} (X,Y)={n \over n-1}\mathrm {Cov} (x_{i},y_{i})={1 \over n-1}\sum _{i=1}^{n}(x_{i}-{\overline {x}})(y_{i}-{\overline {y}})$ Remark:
The distinction between the covariance of a sample and the estimated covariance of the distribution is not always clearly made. This explains why one finds both formulae for the covariance — that taking the mean with " 1 / n " and that with " 1 / (n-1) " instead.

## Properties

The covariance is

• (1) symmetric
• (2) bilinear
• (3) positive definite

because the following holds:

${\text{(1)}}\ \qquad \operatorname {Cov} (X,Y)=\operatorname {Cov} (Y,X)$ ${\text{(2a)}}\qquad \operatorname {Cov} (aX_{1}+bX_{2},Y)=a\cdot \operatorname {Cov} (X_{1},Y)+b\cdot \operatorname {Cov} (X_{2},Y)$ ${\text{(2b)}}\qquad \operatorname {Cov} (X,aY_{1}+bY_{2})=a\cdot \operatorname {Cov} (X,Y_{1})+b\cdot \operatorname {Cov} (X,Y_{2})$ ${\text{(3)}}\ \qquad \operatorname {Cov} (X,X)\geq 0\qquad {\text{and}}\qquad \operatorname {Cov} (X,X)=0\Leftrightarrow X=\mu _{X}\ {\text{almost surely}}$ Since the covariance cannot distinguish between random variables X1 and X2 that have the same deviation, (i.e., X1 − E(X1) = X2 − E(X2) holds almost surely) it does not define an inner product for random variables, but only for random variables with mean 0 or, equivalently, for the deviations.