I am looking at a proof that $\text{Var}(X)= E((X - EX)^2) = E(X^2) - (E(X))^2$
$E((X - EX)^2) =$
$E(X^2 - 2XE(X) + (E(X))^2) =$
$E(X^2) - 2E(X)E(X) + (E(X))^2)$
I can't see how the second line can be equal to the third line. I would have had the following for the third line -
$E(X^2) - E(2XE(X)) + E((E(X))^2))$
Which seems very messy... There must be something I am not understanding about the properties of expected values?
$\endgroup$ 23 Answers
$\begingroup$There are some things you can cancel in yours.
$(E((E(X)))^{2}=(E(X))^{2}$, since the expected value of an expected value is just that. It stops being random once you take one expected value, so iteration doesn't change.
Furthermore, $-E(2XE(X))=-2E(XE(X))=-2E(X)E(X)$ The first step here is just a constant factoring. For the same reason, in the second step, we see that $E(X)$ was actually a constant at this point, not random at all, so it can be factored out as well.
$\endgroup$ 2 $\begingroup$Your intermediate step is correct. All you need to realize is that $E(X)$ is a number, not a random variable, so you can treat it like any other constant, like $2$ or $4$. That is, $E(Y \cdot E(X)) = E(X) E(Y)$, just as you would write $E(Y \cdot 2) = 2 E(Y)$.
$\endgroup$ $\begingroup$$E(X^2-2XE(X)+(E(X))^2)=E(X^2)-E(2XE(X))+E((E(X))^2)$
$=E(X^2)-E(X)E(2X)+(E(X))^2$.
The second term is such because $E(X)$ is a constant, and the expectation of a constant is the constant itself (same for the last term ($E(X))^2$)
$=E(X^2)-2(E(X))^2+(E(X))^2=E(X^2)-(E(X))^2$
$\endgroup$