# How many times to repeat an event with known probability before it has occurred a number of times

If I have a known probability of an event occurring, 1% chance, and I need the event to occur a number of times, 120 times, about how many times would I have to repeat the event before I can expect it to happen that number of times?

• How sure do you want to be that the event will have happened that number of times? – Jake Westfall Jun 12 at 20:47
• Running such an experiment 100 times would have a failure rate of 1 in e. To jake's point, we need more detail to give a valid answer. – JoeTaxpayer Jun 13 at 17:51
• Expecting an event 120 times and needing an event 120 times are widly different things. – Mooing Duck Jun 13 at 18:56
• Somewhere between 120 and infinity. – Bob Jarvis Jun 13 at 22:28

Consider a sequence of $$n$$ independent trials with success probability $$p$$. Let $$X$$ be the number of successes out of the $$n$$ trials. Then $$X$$ has a Binomial distribution with parameters $$n$$ and $$p$$. The expected value of a Binomial rv is $$E(X) = np$$. A simple approach is to set this equal to $$120$$ and solve for $$n$$. Since $$p=0.01$$, we have $$n(0.01) = 120$$ which means that $$n=12,000$$ trials are expected to obtain $$120$$ successes.

Alternatively, here is a related approach that gives the number of trials needed to observe $$r=120$$ successes with some probability $$\gamma$$ (i.e. $$\gamma=0.95$$).

Consider a sequence of independent trials with success probability $$p$$. Let $$X$$ be the number of trials required to observe $$r$$ successes. Then $$X$$ has a Negative Binomial distribution with parameters $$r$$ and $$p$$. In your case, $$X \sim \text{Negative-Binomial}(120, 0.01)$$, and you want to find $$x$$ such that $$P(X \leq x) = \gamma.$$

Although the Negative Binomial distribution has no closed form quantile function, this $$x$$ can be solved for easily. For instance, the answer can be obtained in R by typing: qnbinom(.95, 120, .01). The answer $$x=13728$$ indicates that $$13,728$$ trials are required to have a 95% chance of observing $$120$$ (or more) successes.

• The first method is equivalent to the second with $\gamma = 0.5$, correct? – jpmc26 Jun 13 at 17:32
• @jpmc26 I get 0.5556 for 12000. I used qnbinom(.5556, 120, .01) in here : rextester.com/l/r_online_compiler – Maxter Jun 13 at 17:39
• @jpmc26, the first method will give a similar answer to the second with $\gamma = 0.5$.. but they are not equivalent. The first approach is the expected number of trials (the mean) and the second approach can be thought of as the median number of trials. – knrumsey Jun 13 at 19:08

First, I'm going to assume that the experiments are independent since you said the probably of a success is always 1%. The keyword in your question is "expected," which means we'll be looking for a mean or expected value.

If you are interested in the number of trials $$X$$ (with common probability of success $$p$$), needed to obtain $$r$$ successes, then you can model this as a negative binomial random variable with probability mass function:

$$\begin{eqnarray*} f_{X}(x|r,p) & = & {x-1 \choose r-1}p^{r}(1-p)^{x-r} \end{eqnarray*}$$

for $$x=r,r+1,...,$$

The expected value of the negative binomial is well known as:

$$\begin{eqnarray*} E(X) & = & \frac{r}{p} \end{eqnarray*}$$

In your case, $$p=0.01$$ and $$r=120$$. So the expected number of independent trials of your experiment (times) needed to obtain $$120$$ successes is simply given by $$120/0.01=12,000$$

• Nitpick: Saying the probability is always 1% is not the same as the trials being independent – DreamConspiracy Jun 13 at 23:36
• @DreamConspiracy, no dispute here. I was making an inference from the OP's description. In the case of a N.B. PMF with independent events, it would necessarily be the case that the event probability be constant. – StatsStudent Jun 13 at 23:53

As others have noted, the chance of succeeding enought times will follow a negative binomial distribution. It is useful to plot this, and you can do this in R with:

plot(function(x) pnbinom(x,120,0.01),120,20000)


Which gives:

As you can see it has a sigmoidal shape and there are large areas with virtually no chance and almost certainty and a rapid shift between the two close to the expected value. Therefore, increasing the number of trials may have little effect or a very great effect on the chance of achieving the target depending on how many you've already decided on.

If you scale this function by the number of trails (i.e. mean chance per trial), you can see that there is a clear maximum value,

plot(function(x) pnbinom(x,120,0.01)/x,120,20000)


which you can identify with:

optimise(function(x) pnbinom(x,120,0.01)/x,c(120,20000),maximum=TRUE)
$maximum [1] 13888$objective
[1] 6.929301e-05


As knrumsey says, the number of successes will follow a binomial distribution, but unless you need a high level of precision, 1% is a small enough number that you can use the approximation of a Poisson distribution with $$\lambda=120\frac{1\%}{99\%}=1.2121$$

• How exactly would one "use" this Poisson distribution to answer the question? – whuber Jun 13 at 17:02
• And why are you multiplying $120$ by $1\%$ (rather than dividing one by the other)? – Henry Jun 13 at 17:06
• 1.2 what? trials? – qwr Jun 13 at 20:54
• I like the idea of using the Poisson distribution and am glad you brought it up, but your answer currently is misguided. Letting $F(k,\mu)$ be the value of the Poisson$(\mu)$ CDF and $1-\alpha$ the desired chance of observing at least $n$ occurrences, you can formulate this question as finding the smallest $n$ for which $F(120-1,n\lambda)\le\alpha$ where $\lambda=1/100.$ The answer isn't related to a Poisson$(120\times1/100/(1-1/100))$ distribution! Of interest is the connection with the Gamma distribution: the solution is $F^{-1}_{120-1}(1-\alpha)$ where $F_{120-1}$ is the Gamma$(120-1)$ CDF. – whuber Jun 13 at 22:08