# Expected value of an expected value

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?

• $\mu = E(X)$ is a number, so you need to show that $E(\mu X) = \mu E(X)$ for an RV $X$ – Prahlad Vaidyanathan Feb 14 '14 at 18:07

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.

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)$.

$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$