I have another coin toss question:

Assume I am tossing a biased coin n times with probability p of coming up heads. What is the probability that x heads come up, before y consecutive tails?

A code example would be preferable.

  • $\begingroup$ Just to be clear about what you mean, is HTHTT a case where $x=2$ heads come up before $y=2$ consecutive tails? Or did you mean to say "$x$ consecutive heads"? $\endgroup$ – Barry Cipra Jan 8 '14 at 17:42
  • $\begingroup$ @BarryCipra, Yes, the heads do not need to be consecutive. $\endgroup$ – user27 Jan 8 '14 at 17:46

Consider the following events:

$A_{x,y}$: You observe $x$ heads before $y$ consecutive tails.

$B_{x,y}$: You observe $y$ consecutive tails before $x$ heads.

Let $X_{i}$ follow a Geometric(p). This means that $X_{i}$ denotes the number of tail counts until you observe the first head with a biased coin. Observe that, in particular, $P(A_{1,y}) = P(X_{1} < y)$.

In order to solve for the general case, consider $X_{1},\ldots,X_{x}$ i.i.d. Geometric(p). I claim that:

\begin{align*} P(A_{x,y}) = P(X_{1} < y, \ldots,X_{x} < y) = P(X_{1} < y)^{x} \end{align*}

In order to understand the claim, you can think of $X_{i}$ as the number of observed tails it takes until you observe a head after having already observed $i-1$ heads in the past. Hence, we only need to find $P(X_{1} < y)$. This is well known and equals $1-(1-p)^{y}$.

Hence, in general $P(A_{x,y}) = (1-(1-p)^{y})^{x}$

  • $\begingroup$ Thank you! Though this does not answer my question exactly, since I was asking for a specific maximum number of tosses. On second thought, I don't actually need to know this, so I marked your answer as accepted. $\endgroup$ – user27 Jan 9 '14 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.