# Help with $E(X)^2 = \sum r^2 P(X=r)$

I'm using some Anki flash cards to study statistics and have come across an equation I don't recognize:

$$E(X)^2 = \sum r^2 P(X=r)$$

I found a similar equation in the last line of the proof of the Law of total expectation on Wikipedia.

I'm wondering if someone could point me to a place where this equation is described and possibly some applications for which it is used.

The Card deck is named Tyler GCE Maths S1 - Key facts and equations required for the OCR MEI Mathematics Statistics 1 exam.

-
your equation has a bit problem I guess. it should be $E[X^2]$ –  Seyhmus Güngören Aug 30 '12 at 20:56

As Seyhmus mentioned, this should be $E[X^2] = \sum_r r^2 P(X=r)$. This is valid only for discrete random variables: the version for a continuous random variable with density $f(x)$ is $$E[X^2] = \int_{-\infty}^\infty r^2 f(r)\ dr$$ Both versions are a special case of the "Law of the Unconscious Statistician", which you can look up e.g. in Wikipedia.