# Error count limit for known residual failure rate and desired false-positive rate?

We perform a known fixed number $K$ of independent experiments, each of which has known/assumed residual odds $p$ to fail. We count the number $N$ of failures. How can I choose $M$ so that $N>M$ has odds at most $q$, for some low desired overall false-positive rate $q$?

I'd prefer an approximation based on $q$ and $E = K \cdot p$ only, with a quantitative rule on when this approximation is valid; this should include $10^{-7}\le q\le 10^{-4}$, $0.5 \le E \le 10$, $K\ge 10^4$.

Pointer to an authoritative source is prefered.

My real-life application: I'm designing devices with a self-test (of a physical random number generator) that has a known residual failure rate $p$ when there is no defect. A device self-destructs if the self-test fails more than $M$ times in its life. I want to choose (one of) the lowest $M$ such that failure rate after performing $K$ self-tests is no more than $q$ for devices with no defect.

You want the upper q-quantile point of a Binomial distribution $\text{B}(K,p)$, i.e. $K$ trials each with success probability $p$. As $K$ is large and $p$ is small, you can approximate the Binomial distribution by a Poisson distribution $\text{Pois}(\lambda)$with parameter $\lambda = E = K p$.

For example in R, with $q=10^{-5}, E = 5$:

> qpois(1e-5, 5, lower.tail=FALSE)
[1] 17


The device should self-destruct if it fails 17 or more times. (17 or more, rather than more than 17, due to the precise way the quantile function is defined for a distribution which is only defined on the integers).

To check if this is a good approximation, you can compare it with the exact result from the binomial distribution, e.g. for $K=10^4$ and $p=5\times10^{-4}$ :

> qbinom(1e-5, 1e4, 5e-4, lower.tail=FALSE)
[1] 17