Probability of 20 consecutive success in 100 runs.

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.


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