# Binomial Distribution: Finding the number of trials given probability and successess

Say we want to find the number of trials needed to be 90% sure that we will have at least two or more success, given the probability of a success is say, 50%.

This question is easy when you want to find the number of trials for at least one success, but anything more than one and it gets complicated.

My initial inclination was to find the number of trials needed to get at least one, then multiply it by two, however that isn't the correct answer.

Is there anyway to do this by hand>?

If $X$ is the number of successful trials, then assuming independence of trials $X$ has a Binomial$(n,p)$ distribution where $n$ is the number of trials. Then the probability of at least two successes is \begin{align} P[X \geq 2] &= 1 - P[X = 0] - P[X = 1] \\ &= 1 - \binom{n}{0}p^0q^n - \binom{n}{1}p^1q^{n-1} \\ &= 1 - q^n - npq^{n-1} \\ &= 1 - (n+1)\left(\frac{1}{2}\right)^n. \end{align} Setting this to be greater than or equal to $0.9$ gives $$0.1 \geq (n+1)\left(\frac{1}{2}\right)^n.$$ It happens that this occurs first at $n=7$.

• How about for a number of trials that is very large, say, 20? Is it possible to do by hand?
– Dom
Apr 10 '14 at 7:43
• It will get more complicated, but you could do it using a computer (incidentally, that is how I quickly found n=7). Apr 10 '14 at 7:58

If there are $n$ trials and the probability of success in each is $p$, then the probability of no successes is $(1-p)^n$ and the probability of exactly one success is $n p (1-p)^{n-1}$. The probability of at most one success is then $(1-p)^n + n p (1-p)^{n-1}$, and you want this to be at most $1/10$. To solve that in "closed form" you need the Lambert W function.

• would be nice if you added more explanation about where some of these results came from
– baxx
Jan 25 '18 at 21:17
• @baxx You mean the part about the Lambert W function? Jan 26 '18 at 8:48

Although there is no closed form answer, you can often get a good approximation using the normal distribution with a continuity correction. In your case, we have $$n \geq {1 \over 4}\left(1.28+\sqrt{1.28^2+12} \right)^2 \approx6.2$$

Since $n$ must be an integer, we choose $n=7.$

Note the 1.28 is from the 90th percentile of a standard normal distribution. This version is only valid for $p=0.5$ and your other constraints, but the approximation can be generalized to your needs.

Using normal distribution to approximate binomial distribution: \begin{align}z&=\frac{x-\mu}{\sigma}\\ z&=\frac{x-np}{\sqrt{npq}}\\ z^2 npq &=x^2-2npx+(np)^2\\ p^2 n^2 - (2px+z^2 pq) n + x^2&=0 \end{align} Find

$$n=\frac{-b±\sqrt{b^2−4ac}}{2a} = \frac{2px+z^2 pq\pm\sqrt{(2px+z^2pq)^2−4p^2 x^2 }}{2 p^2 }$$

• Please head to the Mathjax Basic Tutorial $\&$ Quick Reference in order to format your posts. Otherwise, I will recommend deletion. May 21 '18 at 2:12
• Thank you for the edit. I looked at the tutorial and quick reference and do not have the time now to do it. May 23 '18 at 4:48
• Ok. I did not edit, but I did not recommend deletion either :) May 23 '18 at 12:34