# Probability of 20 consecutive success in 100 runs.

Suppose a chess player have a win rate equal 90%, what is the chance to have 20 consecutive wins (successes) playing 100 games? Consider that lose/draw = fail.

I've studied basic statistics in college and it seems like a binomial distribution problem (right?), but honestly I can't figure out a way to solve this problem considering "consecutive" successes.

Is there a statistical distribution for this kinda problem?

Thanks very much! I really appreciate any thoughts!

• There is a formula here: math.stackexchange.com/questions/59738/… – user940 Jun 11 '13 at 19:00
• I believe it is a Bernoulli trial. – Sujaan Kunalan Jun 11 '13 at 19:01
• @SujaanKunalan Bernoulli trials don't require each success to be consecutive. – Ataraxia Jun 11 '13 at 19:03
• @ByronSchmuland: why not $80p^{20}(1-p)^{80}$? – Alex Jun 11 '13 at 19:04
• – lab bhattacharjee Jun 11 '13 at 19:09

Feller has this all worked out on p. 325 of An Introduction to Probability Theory and Its Applications, 3rd Edition, equation 7.11: $$q_n \sim \frac{1-px}{(r+1-rx)q} \cdot \frac{1}{x^{n+1}}$$ where $q_n$ is the probability of no success run of length $r$ in $n$ trials, $p$ is the probability of success, $q=1-p$, and $x$ is the root near 1 of

$$1-x + q p^r x^{r+1} = 0$$

With your data, we find $x \approx 1.017502$ and $q_{100} \approx 0.2247$.

So the probability that the chess player will have at least one run of 20 successes is $0.7753$, approximately.

Edit: Actually "$x$ is the root near 1 ..." is slightly misleading. The equation has two positive roots, and we must peak the one that is not $1/p$. Details here.

• Thanks so much, awkward! This approximation is quite useful and easier to calculate. I was looking for something like that, I really appreciated! – Anthony Jun 16 '13 at 7:21
• @awkward I made an edit to clarify a step in the original recipe, that lead to misleading results. Feel free to edit or undo. – leonbloy Jul 7 '17 at 17:38

Although this summation can't be done easily but I think this will be the exact formula for calculating this probability. Think of $20$ successes together as a single event. Now there are total $80$ + $1$ slot ( I am thinking of $20$ as one single event). Now events in which there are at least a $20$ heads are required for having $20$ consecutive succesess.

Suppose there are $x$ heads in total, $(x \ge 20)$ out of these we are considering $20$ as $1$ big event so probability of having $20$ consecutive successes is $$\binom{81}{x-20+1}p^x(1-p)^{100-x}$$

So our required probability with $p = 0.9$ will be

$$\sum_{x =20}^{100}\binom{81}{x-19}0.9^x\cdot0.1^{100-x}$$

Although this is a nasty summation but I think this is the exact method to find this probability.

Note: I have written it just for the sake of completeness. For computing, method given by @awkward is better.

Here is some R code for simulating this problem. Running the simulation for $10000$ times and setting seed (1236) we get probability $0.7729$

# Generating a single run and counting
# if there are 20 consecutive succeses

consecutiveSuccess <- function(p, count, n) {
trials <- rbinom(n, 1, p)
for (i in 1:(n-count+1)) {
if (sum(trials[i:(i+count-1)]) == count)
return(1)
}
return(0)
}

# simulation starts here
set.seed(1236)
t = 10000
p = 0.9
count = 20
n = 100

sum = 0
for (j in 1:t) {
sum = sum + consecutiveSuccess(p, count, n)
}

prob <- (sum*1.0)/t

• I believe you can speed this up by replacing your loop over i in 1:(n-count+1) with a call to rle(trials) , and looking for any instance of value[k]==1 & length[k]>=20 . – Carl Witthoft Jul 1 '15 at 18:35
• @CarlWitthoft Yeah you are right. I just wrote it quickly (without optimizing) just to get the rough idea of the answer. – abkds Jul 2 '15 at 6:41
• Your summation is incorrect. – gowrath Dec 30 '16 at 20:23
• No the summation is not incorrect. Care to explain. – abkds Dec 31 '16 at 3:42

The probability of getting $20$ consecutive wins is:

$$0.9^{20}$$

The first win of these consecutive wins can be at any trial from $1$ to $80$, and the probability of it being any on any of these trials is evenly distributed, so the probability of getting $20$ consecutive wins out of $100$ is:

$$\frac{80}{100}*0.9^{20}$$

A generalization for this formula would be:

$$\frac{n-k}{n}p^k$$

Where $p$ is the probability, $n$ is the number of trials, and $k$ is the number of consecutive wins.

• That makes total sense to me, but is it correct? I'm just asking because I read the posts that Byron posted (thanks so much, by the way), and I found some really really really tough things to understand - the generating functions by de Moivre in 1738 seems beautiful, but hard to understand intuitively. – Anthony Jun 11 '13 at 19:21
• It is not correct. $0.9^{20}\approx 0.12158$. The formula as given says the chance in a run of $100$ games is less than the chance in a run of 20 games, which is clearly wrong. – Ross Millikan Jun 11 '13 at 19:24
• @Anthony I agree, that's why I tried to come up with an alternative method. Still trying to re-work my current solution because as Ross pointed out, it doesn't work... – Ataraxia Jun 11 '13 at 20:11