I read from a text book that covariance is $E((X - EX)(Y - EY))$. The book then states that this expression is equivalent to $E(XY) - E(X)E(Y)$. Where did the latter expression come from?
Why can covariance be written both of these ways?
1
$\begingroup$
probability
1 Answers
4
$(X-EX)(Y-EY)=XY-(EY)X-(EX)Y+(EX)(EY)$, and expectation is linear, so
$$\begin{align*} E\big((X-EX)(Y-EY)\big)&=E(XY)-(EY)EX-(EX)EY+(EX)(EY)\\ &=E(XY)-(EX)(EY)\;. \end{align*}$$
If you get lost in all the expectations, let $\alpha=E(X)$ and $\beta=E(Y)$; then
$$(X-\alpha)(Y-\beta)=XY-\beta X-\alpha Y+\alpha\beta\;,$$ and
$$\begin{align*} E\big((X-\alpha)(Y-\beta)\big)&=E(XY)-\beta E(X)-\alpha E(Y)+\alpha\beta\\ &=E(XY)-\beta\alpha-\alpha\beta+\alpha\beta\\ &=E(XY)-\alpha\beta\\ &=E(XY)-E(X)E(Y)\;. \end{align*}$$
-
0Thanks, that makes sense overall. I also expanded out the factors, but I'm wondering why we can say that $E(E(Y)X) = EYEX$? – 2012-11-07
-
0@David: Because $E(Y)$ is a constant, the one that I called $\beta$, and $E$ is linear: $E(\beta X)=\beta E(X)$, just as with any linear function. – 2012-11-07
-
0Ah thank you! That makes sense! – 2012-11-07
-
0@David: You’re welcome. – 2012-11-07