What is the expected value of the absolute value of the difference between the number of incoming tails and the number of incoming heads when a coin is tossed 5 times?
Here is what I think : Let $X$ is random variable of number of incoming heads then
$p=\frac{1}{2}$ and $n=5$ so $X\sim Binom(5,\frac{1}{2})$
$X$ and $Y=5-X$ ($Y$ is random variable of number of incoming tails) then $E(K)=E(\left|X-(5-X)\right|)=E(\left|2X-5\right|)=E(2X-5)=2E(X)-5=2.\frac{5}{2}-5=0$ where $K=\left|X-Y\right|=\left|2X-5\right|$ and $E(X)=n.p=5.\frac{1}{2}=\frac{5}{2}$
But the right answer is $\frac{15}{8}$. Where am I making a mistake? Any help will be appreciated.
Best Answer
Your random variable $Z=|X-Y|$ can take only the values
$$\{1,3,5\}$$
with probabilities
$$\left\{\frac{20}{32};\frac{10}{32};\frac{2}{32}\right\}$$
This because
$Z=5$ when you get 5 consecutive tails (or heads)
$Z=3$ when you get 4 tails (or heads)
$Z=1$ when you get 2 tails (or heads)
No other situations are possible.
Thus its expectation is
$$\mathbb{E}[Z]=1\times \frac{20}{32}+3\times\frac{10}{32}+5\times\frac{2}{32}=\frac{15}{8}$$