Lably
Skip to content

Covariance

Measure of the joint variability

  • 9 min read
  • 10 chapters

Related on Lably

Through Statistics, Statistical dispersion and Random variable

Covariance has units of measurement, and the magnitude of the covariance is affected by said units. This means changing the units (e.g., from meters to millimeters) changes the covariance value proportionally, making it difficult to assess the strength of the relationship from the covariance alone. In some situations, it is desirable to compare the strength of the joint association between different pairs of random variables that do not necessarily have the same units. In those situations, we use the correlation coefficient, which normalizes the covariance to a value between -1 and 1 by dividing by the geometric mean of the total variances (i.e., the product of the standard deviations) for the two random variables.

A distinction is made between (1) the covariance of two random variables, which is a population parameter 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-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:

cov⁡(X,Y)=E⁡[(X−E⁡[X])(Y−E⁡[Y])]

where E⁡[X] is the expected value of X, also known as the mean of X. The covariance is also sometimes denoted σXY or σ(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: cov⁡(X,Y)=E⁡[(X−E⁡[X])(Y−E⁡[Y])]=E⁡[XY−XE⁡[Y]−E⁡[X]Y+E⁡[X]E⁡[Y]]=E⁡[XY]−E⁡[X]E⁡[Y]−E⁡[X]E⁡[Y]+E⁡[X]E⁡[Y]=E⁡[XY]−E⁡[X]E⁡[Y]. This identity is useful for mathematical derivations. From the viewpoint of numerical computation, however, it is susceptible to catastrophic cancellation (see the section on numerical computation below).

The units of measurement of the covariance cov⁡(X,Y) are those of X times those of Y. By contrast, correlation coefficients, which depend on the covariance, are a dimensionless measure of linear dependence. (In fact, correlation coefficients can simply be understood as a normalized version of covariance.)

Complex random variables

The covariance between two complex random variables Z,W is defined as cov⁡(Z,W)=E⁡[(Z−E⁡[Z])(W−E⁡[W])¯]=E⁡[ZW¯]−E⁡[Z]E⁡[W¯]

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 (xi,yi) for i=1,…,n, with equal probabilities pi=1/n, then the covariance can be equivalently written in terms of the means E⁡[X] and E⁡[Y] as cov⁡(X,Y)=1n∑i=1n(xi−E(X))(yi−E(Y)).

It can also be equivalently expressed, without directly referring to the means, as cov⁡(X,Y)=1n2∑i=1n∑j=1n12(xi−xj)(yi−yj)=1n2∑i∑j>i(xi−xj)(yi−yj).

More generally, if there are n possible realizations of (X,Y), namely (xi,yi) but with possibly unequal probabilities pi for i=1,…,n, then the covariance is cov⁡(X,Y)=∑i=1npi(xi−E(X))(yi−E(Y)).

In the case where two discrete random variables X and Y have a joint probability distribution, represented by elements pi,j corresponding to the joint probabilities of P(X=xi,Y=yj), the covariance is calculated using a double summation over the indices of the matrix:

cov⁡(X,Y)=∑i=1n∑j=1npi,j(xi−E[X])(yj−E[Y]).

Sign in to keep reading

9 more chapters are free with a Lably account.

More in Statistics and probability