# Expected Value Coins Question

If I were to flip n coins and compute the product of the number of heads versus the number of tails what would be the expected value of this product?

My logic: In n coin flips n/2 coins will be expected to be head and n/2 will be expected to be tails. So the expected value should $n^2/4$

This logic doesn't make sense when you set values for $n$. For example when $n=1$, the expected value using my logic is $1/4$. But regardless, the product will be $0$ because we will get $0$ of either heads or tails.

Similarly, when $n=2$. We can get HH, TT, HT, TH. So in 2 cases we have a product of 0 and in 2 cases we have a product of 1. Adding this together(after multiplying with $1/4$) we get the expected value should be $0.5$. But using my logic the expected value is $1$.

What's wrong with my logic and a hint on how to approach this problem would be awesome! Thanks

• "What's wrong with my logic" The expected value of the product of the number of heads by the number of tails is not the product of the expected value of the number of heads by the expected value of the number of tails. The correct answer is n(n-1)/4. – Did Jan 31 '15 at 22:43

$E[XY]$ is not necessarily $E[X]E[Y]$ if $X$ and $Y$ are not independent. Here the number of tails is dependent on on the number of heads.
In this case, $n^2/4$ is an upper bound on the product random variable (consider maximising $h(n-h)$ by varying $h$), and the maximum possible value if $n$ is even. $0$ is the minimum possible, and has positive probability, so for $n\gt 0$ the expectation of the product must be strictly less than $n^2/4$.
The correct calculation for the expectation is $\displaystyle \sum_{h=0}^n h(n-h){n \choose h}\frac1{2^n}$ which I believe is $\dfrac{n^2}4-\dfrac{n}{4}$.
• $\displaystyle h(n-h){n \choose h} = n(n-1){n-2 \choose h-1}$ and $\displaystyle \sum {n-2 \choose h-1} = 2^{n-2}$ so you end up with $\dfrac{n(n-1)}{2^2}$. – Henry Jan 31 '15 at 23:18