Every builder eventually reports a rate. 36 of 36 checks passed. 19 of 20 users finished the flow. Both are samples, so neither number is the thing you wanted to know. Each is a guess at it, and how good a guess depends on how many times you looked.
The standard way to put error bars on a guess like that is the Wald interval. It is the one in the textbook and the first result for “confidence interval formula”.
p ± 1.96 × √( p(1-p) / n )It is simple and it is famous. At the sample sizes a small team works with, it is also wrong, and wrong in a way you can see with your own eyes.
Four answers it should not be able to give
scripts/wilsonfigs.cjs. The Wilson row calls the
function the product actually publishes numbers with; Wald is written out in the script
because nothing here implements it.- A perfect score gets no uncertainty at all. 36 of 36 comes out as 100% to 100%. Plug in p = 1 and the square root is zero, so the interval has no width. Thirty-six observations, and the formula claims certainty.
- Rates go negative. 1 hit in 20 gives a lower bound of −4.6%.
- Rates go over 100%. 19 of 20 gives an upper bound of 104.6%.
- Finding nothing proves nothing is there. 0 of 20 comes out as 0% to 0%, which would let a tool that found no bugs report that your product has none.
None of those is an edge case you can steer around. They are where the numbers land whenever you measure something that mostly works.
A 95% interval that is right 4% of the time
The failures above are visible. The real problem is not.
An interval labelled 95% is making a promise. Run the experiment over and over and 95% of the intervals you build will contain the true value. That promise can be checked exactly. Fix the number of trials and the true rate, then add up the probability of every outcome whose interval would have covered it.
The flat line is the promise. Wilson tracks it. Wald never reaches it at any true rate on this chart, and its best showing anywhere is 94.7%. At the edges it gives out completely: above a true rate of 99% its real coverage drops under 5%, so a “95% confidence interval” holds the truth one time in twenty-five.
The sawtooth is not noise. Counts are whole numbers, so as the true rate slides the set of outcomes that would cover it changes in jumps, and every method has that shape. What separates Wald is how far below the line its teeth sit, and that they stay there.
The fix is one line
The Wilson score interval inverts the test rather than approximating it, and the result stays inside the range a proportion is allowed to occupy:
centre = (p + z²/2n) / (1 + z²/n), half-width = z√( p(1-p)/n + z²/4n² ) / (1 + z²/n)
Four more terms than Wald, and all four failures go away. 36 of 36 becomes 90.4% to 100%. It still stops at 100%, where a rate has to stop, but it now carries the floor that thirty-six observations buy you. 0 of 20 becomes 0% to 16.1%, which is the right answer to “we looked and found nothing”.
The z²/2n in the numerator is doing the work. It pulls the centre away from the boundary in proportion to how little data you have. That is the correction a small sample needs, and it is the term Wald has no equivalent of.
How to read a rate somebody quotes you
- A rate with no interval is not a measurement. “95% accurate” with no n behind it tells you nothing at all. Ask what the denominator was.
- Be suspicious of a perfect score. 100% from a small sample is the one case where the common formula produces a confident lie, so it is the one most likely to be quoted at you.
- A wide interval is the honest one. 4 out of 16 is 10% to 50%. That is an embarrassing thing to publish and it is what sixteen trials are worth.
- If you report rates, switch the formula. It is a few lines and it removes a class of impossible answer permanently.
We publish our own detector numbers this way, which is how the widest bar in the first figure came to be on this page at all. Our judged layer is 4 of 16. The formula does not care which direction it embarrasses you in, and that is the whole reason to use one.