1

I have this problem which I cant seem to solve. I would really appreciate some help in figuring out where I go wrong. I'm only doing the HH-part below.

(See edit below)

So the problem is

"A fair coin is flipped repeatedly and we count the number of flips required until the first occurence of the pattern HH. Let $X$ be this number and find the expected value of $X$. Then compute the variances of the waiting times for the patterns HH and TH. Use a recursive approach."

So, the first part involving finding the expected value of $X$ (for HH) is solved in the book with an recursive approach using the law of total expectation and conditioning on the outcome of the first two flips.

"There are three different possibilities: (1) the first flip gives T and we start over, (2) the first two flips give HT and we start over and (3) the first two flips gives HH and we are done."

They then solve this recursive equation by simply $E[X] = \mu = E[X|T]P(T)+E[X|HT]P(HT) + E[X|HH]P(HH)$ which gives

$\mu = (1+\mu)\frac{1}{2}+(2+\mu)\frac{1}{4} + 2\frac{1}{4} \implies \mu = 6$.

So far so good, I understand whats going on.

When I now, however, try to use the same approach in calculating $E[X^2]$ (which I later plan to use in Steiner's formula for $var(X)$) something goes wrong. I dont know why, because this should work. Perhaps I misunderstand the problem right from the start.

So, $E[X^2] = t = E[X^2|T]P(T)+E[X^2|HT]P(HT) + E[X^2|HH]P(HH)$

Now I note that $E[X^2|HH] = 2^2 = 4$ and $E[X^2|HT] = E[(X+2)^2]$ because we start over after two flips and thus it becomes $(X+2)^2$. In the same manner,

$E[X^2|T] = E[(X+1)^2]$.

After this, we simply solve for $t = E[X^2] = 8\mu +10$ (after some manipulation of the equation above).

Now, the $var(X) = E[X^2] - (E[X])^2 = 22$. According to the book the answer should however be $10$ (for HH). How can this be?

I would be very glad if someone could help me out on this one. Just nudge me in the right direction.

EDIT: It seems I was right in all my calculations above. Indeed, the answer in the book is wrong. However, I now struggle with the other part of the problem. I.e. for pattern TH. So let now $X$ denote the number of rolls until pattern TH.

I try to solve it in similar way. The difference this time is that if we condition on the first roll, we can either get H or T. And because $X|T \sim Geom(1/2)$, we get a slightly different calculation. I manage to get it wrong either way. The answer should be that the $var(X) = 4$ for TH (this is definitly correct).

We know (from the book) that, $E[X] = \mu = 4$. And $E[X^2] = E[X^2|H]*1/2 + E[X^2|T]*1/2 = E[(X+1)^2]*1/2 + E[X^2|T]*1/2$

and in general for $Y \sim Geom(p)$ we have $E[Y^2] = \frac{2-p}{p^2}$. Thus, in our case $E[X^2|T] = \frac{2-1/2}{1/4} + 1 = 6+1 =7$ and after some simple manipulation of the equation above we have

$E[X^2] = 2\mu + 8$. But this gives (for $\mu =4$) that the $var(X) = 0$ (?!).

What am I doing wrong now? Anyone?

  • All the calculations in your post seem correct to me. Is there some reason you cannot identify the book publicly? One possibility is just human error in preparing the book. For example, mistakenly taking $\mu = 8$ in doing $V = E[X^2] - (EX)^2$ so there's that $10$ left. – Lee David Chung Lin May 01 '18 at 09:36
  • @LeeDavidChungLin A simple Google search reveals the book: https://books.google.com/books?id=mSnG5C3I-iAC&pg=PA194&lpg=PA194&dq=%22A+fair+coin+is+flipped+repeatedly+and+we+count+the+number+of+flips+required%22&source=bl&ots=v5SzBgqGLx&sig=PUsetR2toGj1BZ0zcgpoZoPywDE&hl=en&sa=X&ved=0ahUKEwi9zIS5m-TaAhURZd8KHeZGBHEQ6AEIKDAA#v=onepage&q=%22A%20fair%20coin%20is%20flipped%20repeatedly%20and%20we%20count%20the%20number%20of%20flips%20required%22&f=false – Math1000 May 01 '18 at 09:37
  • Here is a relevant post of mine:https://stats.stackexchange.com/q/303960/119261. Another one: https://math.stackexchange.com/q/73758/321264. – StubbornAtom May 01 '18 at 09:39
  • I didnt think of write out which book Im using. Sorry. But the one linked above is the one. Hmm I'm not sure if there is an error in the book. Perhaps there is. It would seem more likely, however, that I actually did something wrong above. @StubbornAtom : Ok, I will check out your post. Thanks! – tarkovsky123 May 01 '18 at 09:57
  • Edit: Haha apparently this very problem was tagged as having the wrong answer in the book according to my course homepage (I missed this somehow). The right answer is indeed $22$. Great. Thanks for your comments anyway. – tarkovsky123 May 01 '18 at 10:02
  • Variance for geometric is $(2-2p)/p^2$ – Ned May 07 '18 at 16:01
  • Also, when you roll a tail first, the conditional RV is 1 + Geom(1/2) and Expectation of its square is NOT $1 + ( (2-2p)/p^2 )^2$ . – Ned May 07 '18 at 16:10

0 Answers0