Covariance (source code)

= Covariance
{title2=$\operatorname{Cov}(X,Y)$}
{wiki}

The covariance of square-integrable random variables is
$$
\operatorname{Cov}(X,Y)
=\mathbb E[(X-\mathbb EX)(Y-\mathbb EY)].
$$
It determines the variance of a difference through
$$
\operatorname{Var}(X-Y)
=\operatorname{Var}(X)+\operatorname{Var}(Y)-2\operatorname{Cov}(X,Y).
$$