Skip to content

Wilson and Clopper–Pearson intervals

Two binomial confidence intervals: derive Wilson score limits, calculate equal-tail Clopper–Pearson bounds, and compare small-sample coverage and zero-success cases.

Wilson and Clopper–Pearson intervals are two ways to construct a confidence interval for the success probability of a binomial experiment. Wilson uses score-test inversion with a normal cutoff; Clopper–Pearson uses exact binomial-tail probabilities. For a quant estimating an order-fill or breach probability from a small count, they avoid the zero-width interval that the usual Wald formula produces when no events occur.
Both concern an unknown probability, rather than a range for the next outcome. Their guarantees also differ: Wilson coverage is approximate; equal-tail Clopper–Pearson coverage is at least the stated level under the binomial model.

Two successes do not pin down a 20% probability

Suppose a hypothetical execution experiment defines a success as a full fill within one second. Fix the protocol and sample size in advance. Model ten trial indicators as independent Bernoulli variables, each with the same unknown probability pp. Then the success count has the binomial distribution:
K∼Binomial⁡(n,p),p^=kn.K\sim\operatorname{Binomial}(n,p),\qquad \hat p=\frac{k}{n}.
With n=10n=10 and k=2k=2, the observed rate is 0.200.20. The following are two-sided 95% intervals, with no continuity correction for Wilson:
ConstructionLower endpointUpper endpoint
Wilson score0.056682150.50983753
Equal-tail Clopper–Pearson0.025210730.55609546
Raw Wald approximation−0.047918010.44791801

The negative Wald endpoint is impossible for a probability. More consequentially, ten trials leave a wide range of compatible values even with a construction that respects the boundaries. The estimate alone conceals that uncertainty.

For two successes in ten iid trials, 95% Wilson is 5.67%–50.98%, Clopper–Pearson is 2.52%–55.61%, and raw Wald is −4.79%–44.79%. For zero successes, Wilson is 0%–27.75%, Clopper–Pearson is 0%–30.85%, and Wald is 0%–0%.
For two successes in ten iid trials, 95% Wilson is 5.67%–50.98%, Clopper–Pearson is 2.52%–55.61%, and raw Wald is −4.79%–44.79%. For zero successes, Wilson is 0%–27.75%, Clopper–Pearson is 0%–30.85%, and Wald is 0%–0%.
Original hypothetical fixed-sample binomial example. Wilson has no continuity correction; Clopper–Pearson is two-sided and equal-tailed. The raw Wald interval is shown without clipping.

Wilson: put the candidate probability in the variance

Write z=z1−α/2z=z_{1-\alpha/2} for a standard-normal quantile; at 95%, z≈1.95996398z\approx1.95996398. The Wald construction substitutes p^\hat p into the variance and reports

p^±zp^(1−p^)n.\hat p\pm z\sqrt{\frac{\hat p(1-\hat p)}{n}}.

The Wilson construction instead retains candidate values p0p_0 whose score statistic does not exceed the normal cutoff:

∣p^−p0p0(1−p0)/n∣≤z,0<p0<1.\left|\frac{\hat p-p_0}{\sqrt{p_0(1-p_0)/n}}\right|\le z, \qquad 0<p_0<1.

Squaring and solving the resulting quadratic gives

[LW,UW]=p^+z2/(2n)  ±  zp^(1−p^)/n+z2/(4n2)1+z2/n,[L_W,U_W]= \frac{\hat p+z^2/(2n)\;\pm\; z\sqrt{\hat p(1-\hat p)/n+z^2/(4n^2)}}{1+z^2/n},

where minus gives the lower endpoint and plus gives the upper. Include the limiting boundary values when k=0k=0 or k=nk=n.

This inversion, described by NIST, produces endpoints inside [0,1][0,1]. Its centre is (k+z2/2)/(n+z2)(k+z^2/2)/(n+z^2), so it is generally asymmetric around the observed rate. That algebra does not make it a Bayesian posterior interval. The normal cutoff still makes this an approximate confidence procedure.
“Wilson” here means the uncorrected score interval. Software may also offer a continuity-corrected variant; SciPy distinguishes the two explicitly.

Clopper–Pearson: invert the binomial tails

For an interior count 0<k<n0<k<n, equal-tail Clopper–Pearson endpoints solve

Pp=LC(K≥k)=α/2,Pp=UC(K≤k)=α/2.\mathbb P_{p=L_C}(K\ge k)=\alpha/2, \qquad \mathbb P_{p=U_C}(K\le k)=\alpha/2.
A lower candidate probability makes observing at least kk successes too unlikely; an upper candidate makes observing at most kk too unlikely. These exact binomial-tail equations can be evaluated through beta-distribution quantiles. If Bq(a,b)B_q(a,b) denotes the qq quantile of a Beta⁡(a,b)\operatorname{Beta}(a,b) distribution, then
LC={0,k=0,Bα/2(k,n−k+1),k>0,UC={B1−α/2(k+1,n−k),k<n,1,k=n.L_C=\begin{cases} 0,&k=0,\\ B_{\alpha/2}(k,n-k+1),&k>0, \end{cases} \qquad U_C=\begin{cases} B_{1-\alpha/2}(k+1,n-k),&k<n,\\ 1,&k=n. \end{cases}

The boundary conventions matter: substituting a zero shape parameter into a beta quantile is not the way to handle an all-failure or all-success sample. We use closed intervals, including their endpoints. The tail allocation is part of the definition; another two-sided exact-test ordering need not invert to this same interval.

For zero successes in ten trials, the upper equation becomes

(1−UC)10=0.025⇒UC=1−0.0251/10≈0.30849711.(1-U_C)^{10}=0.025 \quad\Rightarrow\quad U_C=1-0.025^{1/10}\approx0.30849711.
Thus zero observed successes still permits a substantial upper endpoint: the two-sided interval is [0,0.30849711][0,0.30849711]. Wilson gives [0,0.27753280][0,0.27753280]. Wald gives [0,0][0,0] because its estimated variance is zero. Clipping Wald to [0,1][0,1] cannot repair that collapse.
For k=nk=n, the corresponding Clopper–Pearson interval is [(α/2)1/n,1][(\alpha/2)^{1/n},1]. A one-sided 95% upper confidence bound instead spends the entire 5% in one tail: for k=0k=0, it is 1−0.051/n1-0.05^{1/n}. It must not be substituted silently for the two-sided endpoint above.

What “exact” buys, and what it costs

For a fixed true pp, coverage is

C(p)=∑k=0n1{L(k)≤p≤U(k)}(nk)pk(1−p)n−k.C(p)=\sum_{k=0}^{n} \mathbf 1_{\{L(k)\le p\le U(k)\}} \binom nk p^k(1-p)^{n-k}.
This sums the probability of every count whose interval covers pp. At n=10n=10 and p=0.10p=0.10, the sum is 92.98% for Wilson and 98.72% for Clopper–Pearson.
Exact binomial probability sums for n ten show Wilson coverage oscillating around 95%, sometimes below it, and Clopper–Pearson coverage at least 95%. At a true success probability of 10%, coverage is 92.98% for Wilson and 98.72% for Clopper–Pearson.
Exact binomial probability sums for n ten show Wilson coverage oscillating around 95%, sometimes below it, and Clopper–Pearson coverage at least 95%. At a true success probability of 10%, coverage is 92.98% for Wilson and 98.72% for Clopper–Pearson.
Original deterministic coverage calculation over every possible success count for n = 10. Curves are separated at endpoint jumps; this is not a Monte Carlo simulation.
Only eleven counts are possible when n=10n=10. As pp crosses an interval endpoint, a count enters or leaves the coverage sum, creating jumps. Clopper–Pearson controls each tail's noncoverage at no more than α/2\alpha/2, so total coverage is at least 1−α1-\alpha. It is generally conservative, rather than exactly 95% at every pp. The R documentation states this guarantee and notes that the interval need not have the shortest length. Its wider range in the worked example is the price of that conservative construction; “exact” does not mean most precise.

Wilson can cross below the nominal line, as the calculation demonstrates. Choosing it means accepting approximate coverage, not acquiring the Clopper–Pearson guarantee with shorter endpoints.

Beta quantiles do not make an interval Bayesian

Clopper–Pearson uses two different beta distributions for its two endpoints. A beta prior Beta⁡(a,b)\operatorname{Beta}(a,b) and the same binomial data instead produce one posterior distribution, using the beta–binomial update:
p∣k∼Beta⁡(a+k,b+n−k).p\mid k\sim\operatorname{Beta}(a+k,b+n-k).

For example, a uniform Beta⁡(1,1)\operatorname{Beta}(1,1) prior with two successes in ten trials produces Beta⁡(3,9)\operatorname{Beta}(3,9). Its equal-tail 95% credible interval is approximately [0.06021773,0.51775585][0.06021773,0.51775585], different from both intervals above. The posterior range has a probability interpretation conditional on the prior and model. A frequentist confidence level describes repeated-sampling coverage; it does not assign 95% probability to this realised range containing a fixed pp.

Finally, neither construction fixes the design. Correlated orders, changing execution conditions or unequal trial probabilities undermine the binomial model. Sampling without replacement from a finite pool may require a hypergeometric model. Repeatedly checking an interval and stopping when it looks favourable also changes the fixed-sample procedure. The adjective “exact” protects the stated binomial calculation, not assumptions that the data fail to satisfy.

For the interval–test connection and the Bernoulli Wald starting point, see Confidence Intervals and Hypothesis Testing: public preview; full lesson requires membership.

Practice: which upper bound?

A prespecified experiment observes zero successes in 20 independent trials with constant success probability. A colleague reports a Clopper–Pearson upper endpoint of 13.91% as part of a two-sided 95% interval. Is the tail convention correct?
Answer. No. The two-sided equal-tail upper endpoint is 1−0.0251/20≈16.84%1-0.025^{1/20}\approx16.84\%, because the upper tail uses 2.5%. The reported 1−0.051/20≈13.91%1-0.05^{1/20}\approx13.91\% is the one-sided 95% upper bound. Both calculations can be valid for their stated designs; their confidence statements differ.

Sources

Last updated
  • binomial inference
  • confidence intervals
  • wilson score
  • clopper pearson
  • coverage
  • boundary cases
← Back to the glossaryBack to top ↑