Canonical: https://knowlpedia.com/probability/covariance/

# Covariance

Expectation of a centered product measuring joint linear variability of two random variables

A **covariance** is the quantity \(\operatorname{Cov}(X,Y)=\mathbb{E}\!\left[(X-\mathbb{E}[X])(Y-\mathbb{E}[Y])\right]=\mathbb{E}[XY]-\mathbb{E}[X]\mathbb{E}[Y]\) associated to two [random variables](https://knowlpedia.com/probability/random-variable/) \(X\) and \(Y\) with finite second moments.

## Remarks

Covariance is built from [expectation](https://knowlpedia.com/probability/expectation/) on a [probability space](https://knowlpedia.com/probability/probability-space/) and generalizes [variance](https://knowlpedia.com/probability/variance/), since \(\operatorname{Cov}(X,X)=\operatorname{Var}(X)\). If \(X\) and \(Y\) are [independent](https://knowlpedia.com/probability/independence-random-variables/) and have finite second moments, then \(\operatorname{Cov}(X,Y)=0\) (but the converse need not hold).

## Examples

- If \(X=\mathbf{1}_A\) and \(Y=\mathbf{1}_B\) are indicator [random variables](https://knowlpedia.com/probability/random-variable/) of events \(A,B\), then \(\operatorname{Cov}(X,Y)=\mathbb{P}(A\cap B)-\mathbb{P}(A)\mathbb{P}(B)\) in terms of [event probabilities](https://knowlpedia.com/probability/event-probability/).
- If \(Y=aX+b\) for constants \(a,b\) and \(X\) has finite second moment, then \(\operatorname{Cov}(X,Y)=a\,\operatorname{Var}(X)\).
- If \(X\) and \(Y\) are independent standard normal [random variables](https://knowlpedia.com/probability/random-variable/), then \(\operatorname{Cov}(X,Y)=0\).
