3

I keep tossing a fair coin until I see HTHT appears. What is the probability that I have already observed the sequence TTH before I stop?

Edit:

Okay. This problem is the same as before. I am trying to think of the following. Could anyone please tell me if this is also the same as before, and if not, how to solve it.

Two players A and B toss two different fair coins. A tosses his coin until he sees HTHT appearing for the first time, and records the number of tosses, $X$. B tosses his coin until he sees TTH appearing for the first time, and records the number of tosses made, $Y$. What is the probability that $Y<X$?

Arturo Magidin
  • 398,050
Qiang Li
  • 4,097
  • 3
    This question is much in the same flavor as both http://math.stackexchange.com/questions/18093/probability-question-related-to-pattern-in-coin-tossing and http://math.stackexchange.com/questions/18405/a-question-related-to-two-competing-patterns-in-coin-tossing; it seems you are not really following the answers you got then, since similar approaches should work here as well... – Arturo Magidin Feb 04 '11 at 21:49
  • In fact, isn't this question equivalent to "I keep tossing a fair coin until I see HTHT or TTH appear. What is the probability that I got TTH?" Then exactly the same approach as in the second question Arturo links to will work. – Mike Spivey Feb 04 '11 at 21:52
  • guys, don't be mad at me. I do not see how this question is the same or can be solved the same way as other questions I posted. This is of a much different flavor, if I am not mistaken. – Qiang Li Feb 04 '11 at 22:08
  • @Qiang: See Mike's comment: it is equivalent to the previous question: assign one pattern to one player, the other pattern to the other player, and compute the probability that the player with the pattern TTH won. I'm not mad, but it really does seem that you aren't really understanding the ideas of the answers you have already "accepted" for other questions. There's little point to the site if you all you want is answers you don't understand. – Arturo Magidin Feb 04 '11 at 22:09
  • @Mike: the question "I keep tossing a fair coin until I see HTHT or TTH appear. What is the probability that I got TTH?" is different from this one since this one is asking: when stopped with the appearance of the first pattern, we are asking for the prob. of the second pattern also appearing. – Qiang Li Feb 04 '11 at 22:11
  • @Arturo: I do not understand why the two questions are the same, and I do not see them the same. – Qiang Li Feb 04 '11 at 22:12
  • @Qiang Li: Please try to think these things through. It's the exact same thing whether you keep tossing after TTH appears or not, the answer will still be "TTH showed up". So you can just as well stop after TTH shows up the first time, if it shows up before HTHT. The probabilities will be the same either way. – Arturo Magidin Feb 04 '11 at 22:13
  • @Qing Li: "I do not understand why the questions are the same." Yes, that is precisely my point. You aren't really understanding the answers, because if you did, you would see why the two questions are the same. Trivial variations in the set-up don't change the mathematical analysis. A trivial change in this question, which cannot affect the answer, transforms this question into the previous one: just stop tossing if TTH shows up, because it does not matter whether you keep tossing or not after it shows up. – Arturo Magidin Feb 04 '11 at 22:15
  • @Arturo: at the least, one of the difference lies in the fact that: when I am stopped at HTHT, I can have multiple TTH before. This contributes to the overall probability. However, in case that either HTHT or TTH appearing, it is not counted. Correct? – Qiang Li Feb 04 '11 at 22:17
  • @Qiang Li: Incorrect; it doesn't contribute to the overall probability, because you aren't asking how many times TTH shows up, just whether it showed up or not. It doesn't matter if it shows up once, twice, three, or a hundred million times, the answer is still "yes, it showed up". You are counting the proportion of sequences in which TTH occurs before HTHT occurs; the only difference is sequences in which HTHT does not occur at all but TTH does, and they are negligible. – Arturo Magidin Feb 04 '11 at 22:27
  • @Qiang Li: I'm not sure your new problem is well-defined. "Two players A and B toss a fair coin" sounds like one coin is being tossed. "A toss X times when he sees HTHT appearing for the first time. B toss Y times when he sees TTH appearing for the first time" sounds like each is tossing a different coin. Which is it? This matters, as the answers should be different. – Mike Spivey Feb 05 '11 at 00:08
  • @Mike: how about this now? – Qiang Li Feb 05 '11 at 00:28
  • @Qiang Li: Better. This new question is different from the one I answered before. – Mike Spivey Feb 05 '11 at 00:34

2 Answers2

2

By the standard techniques explained here in a similar context, one can show that the first time $T_A$ when the word A=HTHT is produced has generating function $$ E(s^{T_A})=\frac{s^4}{a(s)},\qquad a(s)=(2-s)(8-4s-s^3)-2s^3, $$ and that the first time $T_B$ when the word B=TTH is produced has generating function $$ E(s^{T_B})=\frac{s^3}{b(s)},\qquad b(s)=(2-s)(4-2s-s^2), $$ The next step would be to develop these as series of powers of $s$, getting $$ E(s^{T_A})=\sum_{n\ge4}p_A(n)s^n,\quad E(s^{T_B})=\sum_{k\ge3}p_B(k)s^k, $$ and finally, to compute the sum $$ P(T_B<T_A)=\sum_{k\ge3}\sum_{n\ge k+1}p_B(k)p_A(n). $$ An alternative solution is to consider the Markov chain on the space of the couples of prefixes of the words A and B and to solve directly the associated first hitting time problem for this Markov chain, as explained, once again, here.

(+1 to Arturo's and Mike's comments.)

Added later Introduce the decomposition into simple elements $$ \frac1{(1-s)b(s)}=\sum_{i=1}^4\frac{c_i}{1-s\gamma_i}. $$ Then, one can show that $$ P(T_B<T_A)=\sum_{i=1}^4\frac{c_i}{a(\gamma_i)}, $$ by decomposing the rational fractions $1/b(s)$ and $1/a(s)$ into simple elements, by relying on the fact that all their poles are simple, and by using some elementary algebraic manipulations.

At this point, I feel it is my duty to warn the OP that to ask question after question on math.SE or elsewhere along the lines of this post is somewhat pointless. Much more useful would be to learn once and for all the basics of the theory of finite Markov chains, for instance by delving into the quite congenial Markov chains by James Norris, and, to learn to manipulate power series, into the magnificent generatingfunctionology by Herbert Wilf.

Did
  • 279,727
  • @Didier: many thanks! I got the same generating functions. But it looks like that the double summation is still intractable, unless you can please teach me something more. – Qiang Li Feb 05 '11 at 17:39
  • @Didier: thanks for the completed answer, and the warning too. – Qiang Li Feb 05 '11 at 22:19
  • @Didier, I looked at the book by Herbert Wilf, but did not find where it talked about converting the double summation the way you did here. I only found one place he talked about partial fractions, but it is unlike what you did here. Would you please give me some more hint on how to get $$P(T_B \lt T_A)=\sum_{i=1}^4{\frac{c_i}{a(\gamma_i)}}$$? Many thanks again! – Qiang Li Feb 06 '11 at 07:02
  • @Qiang Did you find a proof that $E(s^{T_A})$ and $E(s^{T_B})$ where as written in my post? After that, did you deduce from these expressions some formulas for $p_B(k)$ and $p_A(n)$? Hint: you can use the fact that the polynomials $a$ and $b$ have only simple roots without actually computing the values of these roots, like I did for the inverse of $(1-s)b(s)$. If you do all that, and if you remember what the sum of a geometric series is (and I am sure you do), the Graal will not be far away from your grasp... – Did Feb 06 '11 at 10:09
  • Oops: were as written. – Did Feb 06 '11 at 10:19
  • @Didier: I did obtain $E(s^{T_A})$ and $E(s^{T_B})$, the same expression as yours. I also assumed $$p_B(k)=\sum_{i=1}^3{\alpha_i u_i^k}$$ and $$p_A(n)=\sum_{i=1}^4{\beta_i v_i^n}$$. Then I can simplify $$\sum_{k\ge 3}\sum_{n\ge k+1} {p_B(k) p_A(n)}=\sum_{k\ge 3}{(\sum_{i=1}^3{\alpha_i u_i^k})(\sum_{j=1}^4{\frac{\beta_j v_j^{k+1}}{1-v_j}})}$$. But then I really have no idea about the trick to go forward with your simplification. Could you please shed more light? Many thanks! – Qiang Li Feb 06 '11 at 19:41
  • @Qiang The exponents of $u_i$ and $v_i$ in the formulas for $p_B(k)$ and $p_A(n)$ should be shifted, but nevermind, you will be able to modify this. Let us rather look at your last formula. Fix $i$ and $j$. Then the sum over $k$ has a nice expression, hasn't it? And from there, you could try to remember the definition of the $\alpha_i$, $\beta_j$, $u_i$ and $v_j$... – Did Feb 06 '11 at 20:21
  • @Didier: I have been pondering on this for quite some while, but cannot get it straight. Would appreciate your explanation here in the very last step: to relate the definition of $\alpha_i$, $\beta_j$, $u_i$, and $v_j$. – Qiang Li Feb 06 '11 at 20:36
  • @Qiang As I said, you should 1. correct your formulas for $p_B(k)$ and $p_A(n)$, 2. perform the sum over $k$ as I suggested, and use the result to write a simpler formula for $P(T_B<T_A)$, 3. since this simpler formula involves the $\alpha_i$ and $\beta_j$ and simple fractional functions of the $u_i$ and $v_j$, you could then come back to the definitions of these parameters and try to use these definitions to simplify still further your formula for $P(T_B<T_A)$. – Did Feb 07 '11 at 07:13
  • @Didier, finally I got it. I was being dumb at the summation of k. I was wondering there seems to be quite some algebraic manipulation here. Is there any foresight to see the reason of dividing $(1-s)$ in $1/b(s)$, also about the final $\frac{c_i}{a(\gamma_i)}$? I am just thinking about more general patterns here. Thanks again! – Qiang Li Feb 08 '11 at 19:42
1

This answer addresses the question as originally posted; I made it a community wiki because it is really an extended comment that would not have fit as a comment.

The previous question asked, inter alia, the following: given a two-sided coin with probability $p$ of showing heads, and the coin is tossed until either HTHTH or HTHH appears, how to compute the probability that the pattern we got was HTHTH.

Mike Spivey's answer cast the problem as a two-player game, in which one player wins if the first pattern to show up is HTHTH, and the second player wins if the pattern that shows up first is HTHH, and showed how to obtain the probability that either the first player wins, or the second player wins.

The current problem has a fair coin, and asks that the coin be tossed until a particular pattern, HTHT, shows up, and then asks what is the probability that another pattern, TTH, actually occurs before HTHT shows up.

Think of this problem as a two-player game again: the coin is tossed, until either HTHT or TTH show up. The first player wins if HTHT shows up first, the second if TTH shows up first. The exact same approach as used in the previous question works here to obtain the probability that the second player wins, i.e., the probability that TTH will show up first.

Now, you state in comments that you don't see this problem as the same as that game, because in this problem you keep tossing until HTHT appears, instead of stopping if TTH shows up. Well, take the game described above, and then imagine that the two players are utterly bored and so, if player two wins, they keep tossing the coin until HTHT shows up. Will that change the probability that the second player wins? No. The second player still wins if TTH shows up first, regardless of whether you keep tossing the coin or not after he wins. So the probability that TTH showed up at least once before you hit HTHT is the same, whether you keep tossing after TTH shows up or not, because the number of sequences in which TTH shows up but HTHT never does is negligible, so it will not affect the probability. (The probability that a particular finite pattern never shows up is $0$).

So in the end, the answer to your question is still "the probability that TTH showed up before HTHT shows up is equal to the probability that Player Two wins the game".

Arturo Magidin
  • 398,050
  • let me think about this thoroughly. Thanks for the detailed writeup. I understood completely how to calculate the competing patterns in previous posts; if this problem is the same as before, that is great. :) – Qiang Li Feb 04 '11 at 22:31
  • I have changed my original post a bit. Please let me know your thoughts. Many thanks. – Qiang Li Feb 04 '11 at 23:04