# Show that $E[(X-E[X])^2] = E[X^2]-E^2[X]$

I'm trying to use linearity of expectation, but I seem to be failing somewhere. So if we expand the squared expression:

$$(X-E[X])^2 = (X-E[X])(X-E[X]) = X^2 - 2XE[X] + E^2[X]$$

So we have:

$$E[X^2 - 2XE[X] + E^2[X]]$$

Would the linearity of expectation applied to this be:

$$E[X^2 - 2XE[X] + E^2[X]] = E[X^2] - 2E[XE[X]] + E[E^2[X]]$$

Or is it not possible to use with this equation? How can I show that the two expressions in the title are equivalent to each other?

• Linearity also implies that you can bring constants out of the expectation, and the expectation of a constant is the constant. Apr 15, 2014 at 20:21

Let $E(X)=\mu$. Note that $\mu$ is a constant.
Now, $E[X^2-2XE(X) + E^2(X)]$
$= E[X^2-2\mu X+\mu^2]$
$=E(X^2) - 2\mu E(X)+\mu^2$
$=E(X^2)-2\mu^2+\mu^2$
$=E(X^2)-\mu^2$
$=E(X^2)-E^2(X)$

You're not done using linearity of expectation. Look at your second term: $$E[X E[X]] = E[X\cdot\text{constant}] = \text{constant} \cdot E[X].$$

You've also written $E^2[X]$. I don't know what that means. What you need there is $(E[X])^2$. Then you need to deal with $E[(E[X])^2] = E[\text{another constant}]$.

One problem with writing something like $E^2[X]$ is that it could be taken to mean $E[E[X]]$, which is not at all the same as $(E[X])^2$.

• Thanks for your reply. By $E^2[X]$ I do in fact mean $(E[X])^2$. Apr 15, 2014 at 20:32