Coverage of the Clopper–Pearson interval #
For n Bernoulli trials with unknown success probability p, the exact
confidence interval built from the observed count c is
[p⁻(c), p⁺(c)], p⁻(c) = Q_{α/2}(c, n−c+1), p⁺(c) = Q_{1−α/2}(c+1, n−c),
with the conventions p⁻(0) = 0 and p⁺(n) = 1. This module defines those
total endpoints (cpLo, cpHi) and proves the coverage guarantee
P(p⁻(C) ≤ p ≤ p⁺(C)) ≥ 1 − α, C ∼ Bin(n, p),
for every p ∈ [0,1] and every level 0 ≤ α ≤ 1.
The argument is the classical one. The counts at which the lower endpoint
overshoots the truth form a set A; each c ∈ A satisfies
P(Bin(n,p) ≥ c) < α/2, and A is contained in the upper tail above its own
smallest element, whose probability is exactly one of those small numbers. The
counts at which the upper endpoint undershoots are handled symmetrically with
the largest element and a lower tail. No monotonicity of the endpoints is
needed: containment in the tail above the minimum is automatic.
The mirror of the quantile/CDF adjunction #
The endpoints for an arbitrary observed count #
The Clopper–Pearson lower endpoint for c successes in n trials, with the
convention p⁻(0) = 0.
Equations
- SHSLib.Trigamma.cpLo n c alpha = if c = 0 then 0 else SHSLib.Trigamma.betaQuantile (↑c) (↑n - ↑c + 1) (alpha / 2)
Instances For
The Clopper–Pearson upper endpoint for c successes in n trials, with the
convention p⁺(n) = 1.
Equations
Instances For
The lower endpoint agrees with clopperPearsonLower on the interior
counts: c = j+1 successes in n = j+m+2 trials.
The upper endpoint agrees with clopperPearsonUpper on the interior
counts.
The binomial mass of the upper tail {i ≥ c}, in closed form.
The binomial mass of the lower tail {i ≤ c}, in closed form.
The coverage bound #
Coverage of the Clopper–Pearson interval. If the count C is binomial
with n trials and success probability p, then the exact interval built from
C contains p with probability at least 1 − α.