The **covariance** between $X$ and $Y$ is a summary of their relationship. It’s asking if one variable goes up in value, whether the other variable tends to go up as well (positive covariance) or down (negative).

While in practice we don’t use it as often directly (often, the Correlation is easier to interpret), it is involved in a lot of important topics.

## Definition

Mathematically, it is defined as (using square brackets simply for differentiation):

$Cov(X,Y)=E([X−E(X)]⋅[Y−E(Y)])$Just like Variance, we have another formula that is much easier to work with in practice:

$Cov(X,Y)=E(XY)−E(X)⋅E(Y)$The similarity is not a coincidence. The variance is just a special case of the covariance. Given $X$, we have $Var(X)=Cov(X,X)=E(XX)−E(X)⋅E(X)=E(X_{2})−E(X)_{2}$.

## Properties

- If $X$ and $Y$ are Independent, then $Cov(X,Y)=0$. However, the equation being true does not imply independence.
- $Cov(X,Y)=Cov(Y,X)$
- $Cov(X,c)=0$ for any constant $c$.
- $Cov(aX,Y)=aCov(X,Y)$ for any constant $a$.
- $Cov(X+Y,Z)=Cov(X,Z)+Cov(Y,Z)$
- $Cov(X+Y,Z+W)=Cov(X,Z)+Cov(X,W)+Cov(Y,Z)+Cov(Y,W)$