2

Let the probability of a success in a trial be $p$ (let $q = 1-p$).

We want to know $P(n)$, the probability of 3 (or more) consecutive successes happening at least once in $n$ trials.

$P(3)$ is $p^3$
$P(4)$ is $p^3 + qp^3$

i.e. the first 3 (and then we don't care), OR not the first one but the next three

$P(5)$ is $p^3 + qp^3 + q^2p^3 + qp^4$

If we let $Q(n)$ be $1-P(n)$ and consider further trials to a string of trials with no successes, we see (a 3rd order recurrence relation)

$Q(n)=qQ(n−1)+pqQ(n−2)+p^2qQ(n−3)$ for $n≥3$, $1$ otherwise

This well explained in https://math.stackexchange.com/q/1176022 (thanks @awkward)

My question is: can the solution be written explicitly as a function of $n$.
e.g. Could we solve say $P(20)$ without resorting to a computer program?

  • 1
    The third order recurrence means that if $r_1,r_2,r_3$ are the roots of $x^3-qx^2-pqx-p^2q$ and they are distinct, then your formula is $a_1r_1^n+a_2r_2^n+a_3r_3^n$ for some reals $a_1,a_2,a_3.$ – Thomas Andrews Mar 06 '23 at 15:01
  • But even when $p=1/2,$ the roots are fairly messy. – Thomas Andrews Mar 06 '23 at 15:04
  • 1
    I don't think your computed value for $P(5)$ is correct. – Thomas Andrews Mar 06 '23 at 15:06
  • 1
    Note that in the linked answer, $P$ is the probability of not getting 3 in a row. – eyeballfrog Mar 06 '23 at 15:21
  • $P(n)$ is clearly a polynomial in $p$ for all $n$ and that that polynomial is always divisible by $p^3$. So letting $P(n,p) = p^3 A(n,p)$, the recursion for $A$ is $A(n,p) = 1 + (1-p)[A(n-1,p)+ p A(n-2,p) + p^2 A(n-3,p)]$ with $A(0,p)=A(1,p)=A(2,p)=0$. Checking the first few $A$ suggests that $p^3(1-p)$ is an important quantity in this problem. – eyeballfrog Mar 06 '23 at 18:52
  • Thanks @ThomasAndrews for correction – Rob Wall Mar 07 '23 at 08:45
  • Thanks @Amogh for the same P(5) correction in suggested edit – Rob Wall Mar 07 '23 at 08:46

1 Answers1

2

Yes, you can give an explicit formula for $P(n)$. We will answer the complimentary question, finding the probability that there are never $3$ or more consecutive successes.

First, we find the number of outcomes where there are exactly $k$ successes, with no three successes in a row. There are $n-k$ failures, which divide the successes into $n-k+1$ contiguous blocks. Each block must have at most $2$ successes. Therefore, this is equivalent to counting nonnegative integer solutions to the equation $$ x_{1}+\dots+x_{n-k+1}=k, \\ 0\le x_i\le 2\;\text{ for each $i\in \{1,\dots,n-k+1\}$} $$ This problem is well-known, and the solution is $$ \sum_{i=0}^{n-k+1}(-1)^i\binom{n-k+1}{i}\binom{n-3i}{k-3i} $$ Putting this altogether, $$ 1-P(n)=\sum_{k=0}^n p^kq^{n-k} \sum_{i=0}^{n-k+1}(-1)^i \binom{n-k+1}i\binom{n-3i}{k-3i} $$ Some people would not call this a "closed" form, but it is an explicit formula for $P(n)$, since you are not required to know earlier values of $P(n-i)$ to compute $P(n)$.

Mike Earnest
  • 75,930
  • 1
    Thanks for the excellent answer. I have edited the question so your initial clarification isn't necessary. – Rob Wall Mar 07 '23 at 11:58