2

Suppose I have a biased coin that comes up heads with probability $p$ and tails with probability $1-p$ with some $p$ such that $0 < p < 1$.

I flip the coin $n \geq 1$ times. I choose some $m$ so that $1 \leq m \leq n$.

I am trying to find the probability, in terms of $p$, $n$, and $m$, of the following being true:

During the $n$ tosses, at some point there is a streak of (at least) $m$ consecutive heads.


Let $f(n,m,p)$ be the probability that such a streak exists.

I am trying to find a general formula for $f$ in terms of $n$, $m$, and $p$, but I don't know how to solve this.

I can figure out some of the easier cases, where I fix one of $n$, $m$ or $p$ and write $f$ in terms of the other two variables:


  • $$f(1, m, p) = p$$ (in this case $n=1$ forces $m=1$ and this is just the probability of heads on one flip)

  • $$f(n,1,p) = (1-p)^n$$ (in this case we can find $1$ minus the probability of no heads)

I don't know how to find a general formula (or a good approximation) for $f(n,m,p)$. I am guessing that the problem is very difficult.

Any help is appreciated, thank you!!

Harry
  • 67
  • 2
    This has been asked tons of times, please search. – leonbloy Oct 20 '17 at 03:34
  • wow that formula is crazy ... I am trying to make an excel spreadsheet and I need a pretty simple formula to put in there to calculate $f(n,m,p)$ ... is there maybe an estimation of it? – Harry Oct 20 '17 at 03:39
  • 1
    @HarryGarrott If you have access to a programming language (pretty much anything that isn't excel), you can calculate this fairly easily. If you're looking specifically for an approximation (I doubt a nicer closed form exists), I would recommend posting as a separate question, with specific details about how close an approximation you need, and linking to this. – Carl Schildkraut Oct 20 '17 at 04:03
  • 1
    @HarryGarrott There are several approxmations in the answers, but that depends on the argument range. See eg https://math.stackexchange.com/questions/48560/whats-the-chance-of-an-explicit-series-of-integers-in-a-limited-random-distribu/48584#48584 – leonbloy Oct 20 '17 at 11:36

1 Answers1

2

The general case is much harder than $f(1,m,p)$ or $f(n,1,p)$, but the problem has been solved using generating functions.

The probability $f$ is given by

$$f(n,m,p) = \displaystyle\sum_{k=1}^{\large\lfloor \frac{n}{m} \large\rfloor}\left[\,(-1)^{k+1} \left(p + \frac{(n - km + 1)(1-p)}{k}\right)\binom{n-km}{k-1}p^{km}(1-p)^{k-1}\,\right]$$

See Byron Schmuland's very detailed answer here for references and an explanation of the formula.