I was wondering if you flipped 4 coin tosses, and you get 0.25 dollars for each coin that lands on tails and 0 dollars if it lands on head. How, would you calculate the variance and expected value.
2 Answers
Your reward, $R$, is the number of tails times unit reward, i.e. $R=0.25X$ dollars. Here, $X$ is number of tails out of $n=4$ tosses. It's well known that $X$ is a Binomial RV, and we can use its mean and variance, i.e. $E[X]=np, \operatorname{var}(X)=np(1-p)$, where $p$ is probability of tail, and $n$ is total number of tosses. You haven't specified $p$, but if it is a fair coin, you can just replace $p=1/2$ into the equations.
We can find the expected value and variance of $R$, using $X$'s, i.e. $$E[R]=E[0.25X]=0.25E[X]=0.25np=p$$ $$\operatorname{var}(X)=\operatorname{var}(0.25X)=(0.25)^2\operatorname{var}(X)=(0.25)^2np(1-p)=\frac{p(1-p)}{4}$$
Since 4 coin tosses would be independent events, that means joint probability would be
P(C1,C2,C3,C4) = P(C1)*P(C2)*P(C3)*P(C4)
Since this is a coin toss, there is 0.5 probability to get either heads and tails
There can 2^4 = 16 combinations, out of which 8 would be when you would get some money and 8 would be when you do not get any money.
Following on that, we have following combination when we earn money
TTTT = 0.25 * 4
TTTH = 0.25 * 3
TTHH = 0.25 * 2
THHH = 0.25 * 1
Now, each of the above listed winning cases have a prob (p) = 0.0625 -> (0.5^4) That means by law of large numbers, if you play 10000 games, there will be 625 games each of above combinations where you will get money. Therefore:
TTTT = 0.25 * 4 * 625 * 1 = 625.00
TTTH = 0.25 * 3 * 625 * 4 = 1875.00
TTHH = 0.25 * 2 * 625 * 6 = 1875.00
THHH = 0.25 * 1 * 625 * 4 = 625.00
HHHH = 0 * 0 * 625 * 1 = 0.00
Total = 5000.00
Mean(over 10000 games) = 0.50 (Expectation)
For checking the above through actual code, see below
The above also provides the variance and std deviations.