[Math] Expected value of coin flip sequence

expectationprobabilityrandom variables

I flip a fair coin independently 6 times. This gives me a sequence of heads and tails. For each consecutive 'HTH' in the sequence you win $5.

So I define a random variable X to be the amount of dollars that I win. For example here is what $X=5$ is: $THTHTT$, and $X=10$ is: $THTHTH$. What is the best way to calculate the expected value of X?

Best Answer

We use the method of indicator random variables, and solve the problem for $n$ tosses. For $k=3$ to $n$, let random variable $X_k$ be $1$ if there is an HTH sequence ending at the $k$-th toss, and let $X_k=0$ otherwise. Then the amount $W$ that we win is given by $$W=5(X_3+X_4+\cdots +X_n).$$ By the linearity of expectation we have $$E(W)=5E(X_3)+5E(X_4)+\cdots+5E(X_n).$$ We have $E(X_i)=\Pr(X_i=1)=\frac{1}{8}$, so $E(W)=\dfrac{5(n-2)}{8}$.

Only minor modification is needed for a biased coin that has probability $p$ of landing heads.