# why does $\mathrm{Cov}(x, y) = \mathbb{E}[XY] - \mathbb{E}[X] \cdot \mathbb{E}[Y]$? [closed]

Found this on Wolfram MathWorld:

Covariance provides a measure of the strength of the correlation between two or more sets of random variates. The covariance for two random variates $X$ and $Y$, each with sample size $N$, is defined by the expectation value \begin{align}\operatorname{Cov}(X,Y) =&\; \mathbb E[(X-\mu_X)(Y-\mu_Y)] \tag1\\[2ex] =&\; \mathbb E[XY]-\mu_X\mu_Y .\tag2\end{align}

A link is probably better. http://mathworld.wolfram.com/Covariance.html. I'm looking for a proof of equation $(2)$ on that page.

• It seems like a definition, not something you would prove. Commented Apr 19, 2018 at 23:03
• @Arthur I think the question is why the two expressions $E[(X - \mu_X) (Y - \mu_Y)]$ and $E[XY] - \mu_X \mu_Y$ are equal. Commented Apr 19, 2018 at 23:04

The proof is not that hard actually. Let $X$ and $Y$ be any two random variables. By definition, we have: $$\text{Cov}(X,Y) = \mathbb{E}[(X - \mathbb{E}(X))(Y - \mathbb{E}(Y))]$$ But we can simply rewrite this and use the linearity of the expactation to obtain: \begin{align*} \text{Cov}(X,Y) &= \mathbb{E}[(X - \mathbb{E}(X))(Y - \mathbb{E}(Y))] \\ &= \mathbb{E}[XY - \mathbb{E}(X)Y - X\mathbb{E}(Y) + \mathbb{E}(X)\mathbb{E}(Y)] \\ &= \mathbb{E}(XY) - \mathbb{E}(X)\mathbb{E}(Y) - \mathbb{E}(X)\mathbb{E}(Y) + \mathbb{E}(X)\mathbb{E}(Y) \\ &= \mathbb{E}(XY) - \mathbb{E}(X)\mathbb{E}(Y) \end{align*}
Call $\mu_X = \mathbb{E}[X]$ and $\mu_Y = \mathbb{E}[Y]$