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>?
$\endgroup$4 Answers
$\begingroup$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$.
$\endgroup$ 2 $\begingroup$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.
$\endgroup$ 2 $\begingroup$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.
$\endgroup$ $\begingroup$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 }$$
$\endgroup$ 3