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 p^(1−p^)/n\sqrt{\widehat p(1-\widehat p)/n} 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.

Keep the interval target explicit
Two-sided 95% intervalOne-sided 95% bound00.00140.00280.0042Probability
Two-sided 95% intervalOne-sided 95% bound00.00140.00280.0042Probability
one-sided upper=1−0.051/n\text{one-sided upper}=1-0.05^{1/n}
one-sided upper=1−0.051/n\begin{gathered}\text{one-sided upper}\\=1-0.05^{1/n}\end{gathered}
Reference illustration. Constructed record: zero failures in 1,000 independent binomial trials. The exact two-sided interval and one-sided upper bound are positive. Their confidence conventions differ; observing zero is not proof of no risk.

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.

Tools
About Python ↗

The code is editable. Press Ctrl+Enter or ⌘+Enter to run Python from the editor.

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?

Back to the Python editor

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?

Choose an answer
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.

Your notes