A rare-event proportion needs a bounded interval that remains informative when the observed count is zero.
Rare proportions: keep interval uncertainty visible at zero and one
Define the trial before the fraction
A fulfillment center records damaged packages among inspected shipments. The numerator is a confirmed damage count; the denominator is shipments inspected under a fixed policy, not every package mentioned in a complaint queue. Choose the reporting window and inspection eligibility before computing a rate. If inspection is targeted at suspicious packages, the observed fraction estimates the inspected group, not all shipments. The sampling frame is part of the result.
Avoid a collapsed uncertainty band
A plain estimate is damaged divided by inspected. The familiar normal interval can produce a negative lower bound or a zero-width result when no damage is observed. A Wilson score interval stays within zero and one and retains positive width at the boundary. Specify the confidence level through its normal critical value, and show the count beside the interval. Zero observed damage in a small sample is not evidence that the true rate must be zero. Coverage interpretation still applies: the procedure has a repeated-sample target.
Check independence and changing inspection
The calculation below treats inspected outcomes as independent Bernoulli trials with one rate. Packages from one supplier batch can fail together; repeated inspections of the same package are not new trials. A policy change that directs inspectors toward risky suppliers changes the sampling frame even if the underlying shipment quality stays fixed. Count supplier batches, show inspection share and consider a design-aware interval when dependence is material. Cluster uncertainty addresses grouped observations rather than pretending each scan is independent.
Use the interval in a decision
Compare the interval with a predeclared operational limit rather than declaring success from a point estimate below it. If the upper bound remains above the limit, the evidence cannot yet establish the desired rate under this design. More representative inspections may narrow the interval; repeated scans of the same batch often will not. Exposure rates cover events per unit time rather than binary outcomes per package, and the project keeps those denominators separate.
Implementation
from math import sqrt
def wilson_damage_interval(damaged, inspected, critical=1.96):
if inspected <= 0 or not 0 <= damaged <= inspected or critical <= 0:
raise ValueError("invalid damage counts or critical value")
rate = damaged / inspected
scale = 1 + critical ** 2 / inspected
center = (rate + critical ** 2 / (2 * inspected)) / scale
half = critical * sqrt(rate * (1 - rate) / inspected +
critical ** 2 / (4 * inspected ** 2)) / scale
return center - half, center + half
lower, upper = wilson_damage_interval(0, 47)
assert lower >= 0
assert 0 < upper < 1
Performance and operating cost
The interval takes O(1) time and space after the count is validated. Its computational cost is trivial beside representative inspection and confirmation. The formula does not repair batch dependence, selective inspection or misclassified damage; those limitations can dominate the apparent precision.
Common Mistakes
- Reporting a zero rate as proof that no damage risk exists.
- Using a normal interval that collapses to zero width at zero events.
- Counting repeated scans of the same package as independent trials.
- Applying an inspected-package interval to all shipments after targeted inspection.
Read next
- Event counts and exposure: compare rates across unequal observation time
- Project: audit rare damage and machine stoppage reports
- Confidence intervals: interpret coverage and precision honestly
- Population, estimand and sampling frame: name the quantity before calculating
- Standard error and cluster bootstrap: resample the independent unit
Continue the workflow: Diagnostic performance: separate sensitivity, specificity and predictive value.
Continue the workflow: Sparse contingency tables: exact conditional inference for a two-by-two contrast.
Continue the workflow: P charts: monitor defect fractions with subgroup-specific denominators.
