2

How can I calculate the number of times I need to repeat an independent test with a probability (p) in order to have 99% confidence that I will have at least 1 true result?

Example: I have a task that has a 20% chance of succeeding (p=0.2). How many times should I expect to repeat the task before I can be reasonably (99%) sure of a successful outcome?

Matt
  • 23
  • 1
    Check out the binomial distribution, and ideas about Bernouli trials:http://en.wikipedia.org/wiki/Binomial_distribution – rajb245 Apr 23 '13 at 23:24

1 Answers1

2

The probability of at least one true result is one minus the probability of no true results in $n$ trials. The probability of getting exactly $k$ sucesses in $n$ trials with probability $p$ is given by the binomial probability mass function $$ f(k;n,p) = \binom{n}{k}p^k (1-p)^{n-k} $$

$$ P(\text{at least 1 success}) = 1-P(\text{exactly 0 sucesses}) = 1-f(0;n,p) $$ $$ f(0;n,p) = (1-p)^{n} $$ Set that equal to $0.99$ for $99\%$, plug in your $p$, and you'll see that you go up in $n$ until $f(0;n,p)$ is less than $0.01$. If you want a closed form expression, call the confidence as $\alpha$:

$$ P(\text{at least 1 success}) = \alpha $$ $$ 1-(1-p)^{n} = \alpha $$ $$ (1-p)^{n} = 1-\alpha $$ $$ \log\left((1-p)^{n}\right) = \log(1-\alpha) $$ $$ n\log\left(1-p\right) =\log(1-\alpha) $$ $$ n=\frac{\log(1-\alpha)}{\log\left(1-p\right)} $$

rajb245
  • 4,755
  • 15
  • 34