What is the uncertainty (68% confidence level) of $N/M$, where $N$ is the number of entries that pass a cut and $M$ is the total number of entries? ($N$ and $M$ are both integers, and I'm interested in the extreme where $N$ or $M - N$ is a small integer, maybe zero.)
In the past, I've always assumed a Binomial model, where $N$ is the number of coin tosses that come up heads and $M$ is the total number of coin tosses. Following this logic, I've used the variance $Mp(1-p)$ to conclude that the uncertainty is $\sqrt{\frac{p(1-p)}{M}}$ (with $p=N/M$). However, I'm beginning to think this is flawed: this "uncertainty" is exactly zero if $p=0$ or $p=1$. Getting five heads in a row shouldn't lead one to conclude that the coin will always yield heads with perfect certainty.
In general, I think the upper uncertainty will be different from the lower uncertainty; that it should come from some integration that has a hard cut-off at $p=0$ and $p=1$, introducing an asymmetry close to the border. Should this come from a Bayesian formalism because I'm making inferences about an unknown distribution from measurement?
(I'm also surprised that I haven't found an answer online: I would have thought it to be a very common problem. Putting uncertainties on trigger efficiencies in physics, for instance.)
binom
package and en.wikipedia.org/wiki/Binomial_proportion_confidence_interval where I found (too many) answers to my question. Do you mind if I write it up as an answer to my own question? $\endgroup$