# Expected value of coin flip sequence

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? ## 2 Answers 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.

There are 64 possible outcomes.
In how many do the first three coins give you HTH?
In how many do coins 2,3,4 give you HTH?
3,4,5?
4,5,6?
What is the total number of HTH from the 64 outcomes?

• Yeah so the hard part of this is figuring out how many sequences of HTH there will be. Counting this when its only 3 coin flips is trivial. Do you have a suggestion of how I can count the amount of these sequences in coin flips of 6? – Steph Dec 21 '15 at 15:38