Expansion of variance in terms of expected value From page 1 (page 13 in the .pdf file), equations 1.3 and 1.4, in this book I find out that
$var[r] = E[(r - E[r])^2] = E[r^2] - (E[r])^2$
Is this true in general and how do I show that it is true?
I have started by expanding
$E[(r - E[r])^2] = E[(r - E[r])^2] = E[r^2 + (E[r])^2 - 2 \cdot E[r] \cdot r]$
How do I continue?
 A: You may proceed as follows:
$$
E[r^2+(E[r])^2-2E[r]r] = E[r^2]+E[E[r]^2]-E[2E[r]r] = E[r^2]+E[r]^2-2E[r]E[r] = E[r]^2-E[r]^2
$$
Note: $E[r]$ is a constant. So it can come out of $E$ as you see for example in $E[2E[r]r] = 2E[r]E[r]$.
A: This question is a bit old, but I would still like to clarify in details how do you actually obtain $E[r^2]−(E[r])^2$ starting from:
$$E[(r - E[r])^2] = E[(r - E[r])^2] = E[r^2 + (E[r])^2 - 2 \cdot E[r] \cdot r]$$
because it could not be obvious for a newbie.
So far, we are here:
$$E[r^2 + (E[r])^2 - 2 \cdot E[r] \cdot r]$$
If we assert that $r$ is our set of $n$ elements:
$$r = \{ r_1, r_2, r_3, r_4, ... r_n \}$$
and that $E[r]$ is the mean $\mu$, then we know that:
$$E[r] = \mu = \frac{1}{n} \sum\limits_{i=1}^n r_i$$
So we can go on and rewrite the formula as a summation:
$$
E[r^2 + (E[r])^2 - 2 \cdot E[r] \cdot r] = \\
\frac{1}{n} \biggl(\sum\limits_{i=1}^n r^2_i + E[r]^2 - 2 \cdot E[r] \cdot r_i \biggr)
$$
And leverage the properties of summations:
$$
\frac{1}{n} \biggl(\sum\limits_{i=1}^n r^2_i + E[r]^2 - 2 \cdot E[r] \cdot r_i \biggr) = \\
\\
\frac{1}{n} \biggl(\sum\limits_{i=1}^n r^2_i + \sum\limits_{i=1}^n E[r]^2 - \sum\limits_{i=1}^n 2 \cdot E[r] \cdot r_i \biggr) = \\
\\
 \frac{\sum\limits_{i=1}^n r^2_i}{n} + \frac{\sum\limits_{i=1}^n E[r]^2}{n} - \frac{\sum\limits_{i=1}^n 2 \cdot E[r] \cdot r_i}{n}
$$
Now, take a look at the last term:
$$\frac{\sum\limits_{i=1}^n 2 \cdot E[r] \cdot r_i}{n}$$
Again, if we use the summations' properties:
$$
\frac{\sum\limits_{i=1}^n 2 \cdot E[r] \cdot r_i}{n} = 
\\
2 \cdot E[r] \cdot \frac{\sum\limits_{i=1}^n r_i}{n}
$$
We can effectively see that this multiplication has the mean in one of its terms!
$$
2 \cdot E[r] \cdot \frac{\sum\limits_{i=1}^n r_i}{n} = 
2 \cdot E[r] \cdot \frac{1}{n} \sum\limits_{i=1}^n r_i =
\\
2 \cdot E[r] \cdot \mu = 2 \cdot E[r] \cdot E[r]
$$
So, let's go back to the whole formula we are expanding:
$$
\frac{\sum\limits_{i=1}^n r^2_i}{n} + \frac{\sum\limits_{i=1}^n E[r]^2}{n} - \frac{\sum\limits_{i=1}^n 2 \cdot E[r] \cdot r_i}{n} = 
\\
\frac{\sum\limits_{i=1}^n r^2_i}{n} + \frac{\sum\limits_{i=1}^n E[r]^2}{n} - 2 \cdot E[r] \cdot E[r]
$$
We proceed similarly with the other two terms:
1) 
$$\frac{\sum\limits_{i=1}^n r^2_i}{n} = 
\\
\frac{1}{n}\sum\limits_{i=1}^n r^2_i = E[r^2]
$$
2)
$$\frac{\sum\limits_{i=1}^n E[r]^2}{n} =
\\
\frac{1}{n}\sum\limits_{i=1}^n E[r]^2 = E[E[r]^2] = \frac{1}{n} \cdot  \biggl(n \cdot E[r]^2\biggr) = E[r]^2
$$
And finally we get:
$$
E[r^2] + E[r]^2 - 2 \cdot E[r] \cdot E[r] = E[r^2] + E[r]^2 - 2E[r]^2 = E[r^2] - E[r]^2
$$
Which is what the OP was asking.
Hope this helps someone.
