Understand simulation errorLesson 17 of 76 · 8 min
When zero failures is not zero risk
Report probability uncertainty without treating an unobserved event as impossible.
For independent yes/no trials, estimate event probability by event count divided by n. The plug-in standard error inserts that estimated fraction. With no observed failures it becomes zero, even though a rare model event may simply have been missed.
An exact binomial confidence interval uses binomial tails instead of this normal approximation. SciPy's binomtest returns a test record; call its proportion_ci method with method="exact" for a two-sided interval. Across repetitions, coverage is at least the stated level for independent trials with one common probability. Exact refers to that model calculation, not certainty about reality.
Two-sided 95% allocates 2.5% to each tail. A one-sided 95% upper bound allocates 5% to the lower-count tail: the probability of seeing zero failures at that upper probability is 0.05. With zero among n trials, solving (1-p)^n=0.05 gives upper bound 1−0.05^(1/n). The two conventions therefore have different upper limits.
Can a finite run with zero failures rule out all positive failure probabilities?
Write a prediction (optional)
Constructed simulation record
Select Run Python below with the code unchanged.
A saved draft is open. To run the published example, open Tools and select Restore example. Recover draft brings your code back.
Execution error
Technical error details
Your result
Published example output
This result comes from the original Python. Your runs appear above. Build environment ↗
Observed failure fraction: 0.0 Two-sided 95% exact interval: 0.0 0.003682 One-sided 95% upper bound: 0.002991 Naive plug-in SE: 0.0
Read the first result
The zero plug-in error estimate is not useful evidence of impossibility. The positive upper bounds quantify what the finite observation leaves unresolved under the binomial model.
Try an edit
Replace n, failures = 1000, 0 with n, failures = 10000, 0. Select Run Python again. Compare Two-sided 95% exact interval and One-sided 95% upper bound with the first run. What evidence would justify reporting the larger count of failure-free trials?
Scope. Independent Bernoulli trials are assumed. The interval does not account for uncertainty in the failure model itself.
Try a fresh case
You simulate a rare event 100 times and never see it. What should you report?
Need a hint?
Hint 1
Ask how often a rare event might be missed in a short run.
Hint 2
Use a probability interval that behaves sensibly at the boundary.