Expected values of squares Question A fair coin is tossed three times. Let Y be the random variable that denotes the square of the number of heads. For example, in the outcome HTH, there are two heads and Y = 4. What is E[Y]?
My answer: 
possible outcomes to toss a coin three times : 0, 1, 2, 3
possible outcomes of Y : 0, 1, 4, 9
E[Y] = (1/6 * 0) + (1/6 * 1) + (1/6 * 4) + (1/6 * 9)
Is it ok? Thanks! 

In this particular case the probabilities of 0, 1, 2, and 3 heads are 1/8, 3/8, 3/8, 1/8 and so 
$$ E(Y) = (1/8) \times 0^2 + (3/8) \times 1^2 + (3/8) \times 2^2 + (1/8) \times 3^2 = 3. $$
In general for $n$ tosses, you have $E(Y) = E(X^2)$ where $X$ is a binomial(n, 1/2) random variable.  Furthermore $E(X^2) = E(X)^2 + Var(X)$.  It's well-known that $E(X) = n/2, Var(X) = n/4$, and so you have $E(X)^2 = (n/2)^2 + n/4 = n(n+1)/4$.  Felix Marin already proved this by  a different route.
