Tutorials › VEE Mathematical Statistics › Wilson Intervals Near Zero And One

VEE Mathematical Statistics · Intervals for Variances and Proportions · Tutorial 575 of 880

Wilson Intervals Near Zero And One

Calculate and interpret Wilson score intervals when observed proportions lie near zero or one, including why the interval endpoints remain valid at the boundaries.

Intermediate 10 min read

What You'll Learn

  • State the binomial assumptions behind a Wilson score interval.
  • Derive the Wilson endpoints by inverting the score inequality for interior parameter values.
  • Obtain the correct closed-interval endpoints when the sample has zero or all successes.
  • Calculate Wilson intervals for sparse successes or failures and interpret their behavior.
  • Recognize why substituting a boundary estimate into a Wald interval can fail.
  • Distinguish the closure of the accepted score set from evaluating the score statistic at a boundary.

Why Boundary Proportions Need Care

A sample proportion of zero or one can occur even when the underlying success probability is not zero or one. For example, a small hypothetical study may observe no claims meeting a specified severity threshold, while the population probability of such a claim remains uncertain. An interval that reports no uncertainty in this situation would be misleading.

The Wilson score interval is useful near these boundaries because it is obtained by inverting a score test rather than by placing a symmetric margin around the observed proportion. It stays within the possible range of probabilities, from zero to one, and remains nonzero in width when every observation has the same outcome. Its nominal confidence level is approximate, as it relies on a normal approximation to a binomial score statistic.

Model and definition: Suppose \(X\) is the number of successes in a fixed sample of \(n\) independent Bernoulli trials, each with the same unknown success probability \(p\), where \(0\leq p\leq1\). Then \(X\sim\operatorname{Binomial}(n,p)\), and the observed sample proportion is \(\hat p=x/n\). For a two-sided confidence level \(1-\alpha\), let \(z=z_{1-\alpha/2}\), the corresponding standard normal quantile. The Wilson score interval is the closure of the values \(p\) in the interior \(0<p<1\) that satisfy the score inequality.

The assumptions matter: the number of trials is fixed, outcomes are independent, and the success probability is common across trials. If observations are dependent or have different success probabilities, this binomial interval is not justified without a suitable model adjustment. In the calculations below, a 95% interval uses \(z=1.96\); probabilities are reported to four decimal places.

Inverting the Score Inequality

For an interior candidate value \(0<p<1\), the binomial score statistic, written in terms of the sample proportion, is \((\hat p-p)/\sqrt{p(1-p)/n}\). The two-sided score acceptance condition is therefore:

$$ \frac{|\hat p-p|}{\sqrt{p(1-p)/n}}\leq z,\qquad 0<p<1. $$

The restriction \(0<p<1\) is essential: at \(p=0\) or \(p=1\), the denominator is zero, so the displayed statistic is not defined. The interval endpoints are obtained by solving the condition for interior \(p\), then taking the closure of the accepted set. They are not obtained by evaluating this statistic at a boundary parameter.

For an interior candidate \(p\), both sides of the inequality are nonnegative, so squaring and multiplying by the positive quantity \(np(1-p)\) gives an equivalent inequality. Substituting \(\hat p=x/n\) gives:

$$ n(\hat p-p)^2\leq z^2p(1-p) $$
$$ (n+z^2)p^2-(2x+z^2)p+\frac{x^2}{n}\leq0. $$

The accepted interior values lie between the roots of this quadratic. Applying the quadratic formula and simplifying gives the usual Wilson endpoints:

$$ \left[ \frac{\hat p+\dfrac{z^2}{2n}}{1+\dfrac{z^2}{n}} - \frac{z}{1+\dfrac{z^2}{n}} \sqrt{\frac{\hat p(1-\hat p)}{n}+\frac{z^2}{4n^2}}, \quad \frac{\hat p+\dfrac{z^2}{2n}}{1+\dfrac{z^2}{n}} + \frac{z}{1+\dfrac{z^2}{n}} \sqrt{\frac{\hat p(1-\hat p)}{n}+\frac{z^2}{4n^2}} \right]. $$

An equivalent form, often convenient when the observed count \(x\) is given, is:

$$ \left[ \frac{x+\dfrac{z^2}{2}-z\sqrt{\dfrac{x(n-x)}{n}+\dfrac{z^2}{4}}}{n+z^2}, \quad \frac{x+\dfrac{z^2}{2}+z\sqrt{\dfrac{x(n-x)}{n}+\dfrac{z^2}{4}}}{n+z^2} \right]. $$

The algebra identifies the roots, but boundary cases require one additional step: the score inequality was defined only for interior \(p\). When \(x=0\), the condition for \(0<p<1\) reduces to:

$$ \sqrt{\frac{np}{1-p}}\leq z \quad\Longleftrightarrow\quad 0<p\leq\frac{z^2}{n+z^2}. $$

Thus the accepted interior set has closure \(\left[0,z^2/(n+z^2)\right]\). The endpoint zero belongs to the reported closed interval as a limit point; the score statistic at \(p=0\) is still undefined. By symmetry, when \(x=n\), the accepted interior set has closure \(\left[n/(n+z^2),1\right]\). These boundary results also agree with the simplified endpoint formula.

Worked Calculations Near Zero and One

Worked Example: No Observed Successes

A hypothetical audit classifies 20 independent files as either having or not having a specified exception. No file has the exception. Calculate a 95% Wilson interval for the exception probability \(p\), using \(z=1.96\).

Method. Here \(n=20\), \(x=0\), and \(\hat p=0/20=0\). Since this is a boundary count, use the closure of the interior score-accepted set. Its endpoints are zero and \(z^2/(n+z^2)\).

Calculation. First, \(z^2=1.96^2=3.8416\), so the upper endpoint is:

$$ \frac{3.8416}{20+3.8416} =\frac{3.8416}{23.8416} =0.1611 $$

The interval is \([0.0000,0.1611]\), to four decimal places. It does not claim that the true probability is zero; it says that zero observed exceptions in 20 trials is compatible with probabilities extending above zero under this interval procedure. The common mistake is to report \([0,0]\) from a zero Wald standard error. Wilson instead gives a positive upper endpoint. The endpoint zero is included by closure, not because the score statistic was evaluated there.

Worked Example: One Success in a Small Sample

A hypothetical screening process is applied independently to 50 units, and exactly one unit meets a rare-event criterion. Find the 95% Wilson interval for the probability of meeting the criterion, using \(z=1.96\).

Method. Use the count form of the Wilson formula with \(n=50\), \(x=1\), and \(z^2=3.8416\). First calculate the common denominator and the square-root term:

$$ n+z^2=50+3.8416=53.8416, \qquad \frac{x(n-x)}{n}+\frac{z^2}{4} =\frac{1(49)}{50}+\frac{3.8416}{4} =0.98+0.9604=1.9404. $$

The square root is \(\sqrt{1.9404}\approx1.3930\), and \(1.96(1.3930)\approx2.7303\). The center numerator is \(x+z^2/2=1+1.9208=2.9208\). Therefore:

$$ L=\frac{2.9208-2.7303}{53.8416} =\frac{0.1905}{53.8416} \approx0.0035, \qquad U=\frac{2.9208+2.7303}{53.8416} =\frac{5.6511}{53.8416} \approx0.1050. $$

The 95% Wilson interval is \([0.0035,0.1050]\), to four decimal places. The estimate \(1/50=0.0200\) is inside the interval, which is a useful arithmetic check. The common mistake is to treat one success as enough to justify a narrow, symmetric interval: here the small count produces appreciable uncertainty, and Wilson's interval is not symmetric about \(0.0200\).

Worked Example: Nearly Every Trial Is a Success

In a hypothetical reliability check, 39 of 40 independent components pass. Calculate a 95% Wilson interval for the pass probability \(p\), using \(z=1.96\).

Method. There are \(n=40\) trials and \(x=39\) successes. To make the near-one behavior transparent, compute the Wilson interval for the failure probability \(q=1-p\), for which there is one failure, then reflect that interval: if \(q\in[L_q,U_q]\), then \(p\in[1-U_q,1-L_q]\).

For \(q\), use \(x=1\) in the count formula. The denominator is \(40+3.8416=43.8416\), the center numerator is \(1+3.8416/2=2.9208\), and the quantity under the square root is:

$$ \frac{1(39)}{40}+\frac{3.8416}{4} =0.9750+0.9604=1.9354. $$

Thus \(\sqrt{1.9354}\approx1.3912\), and \(1.96(1.3912)\approx2.7267\). The failure-probability endpoints are:

$$ L_q=\frac{2.9208-2.7267}{43.8416} =\frac{0.1941}{43.8416}\approx0.0044, \qquad U_q=\frac{2.9208+2.7267}{43.8416} =\frac{5.6475}{43.8416}\approx0.1288. $$

Reflecting and rounding only at the final step gives the interval for \(p\):

$$ [1-U_q,1-L_q] =[1-0.1288,1-0.0044] =[0.8712,0.9956]. $$

The interval contains the observed proportion \(39/40=0.9750\) and stays within \([0,1]\). The common mistake is to treat the 39 passes as if they were a small number of successes near zero, rather than a small number of failures near zero; reflecting the failure interval correctly reverses the endpoint order.

Interpreting Boundary Behavior

The count-based formula makes the two extreme cases especially clear. With no successes, \(x=0\), its lower endpoint is zero and its upper endpoint is \(z^2/(n+z^2)\). With all successes, \(x=n\), its lower endpoint is \(n/(n+z^2)\) and its upper endpoint is one. Both intervals have positive width for finite \(n\) and positive \(z\).

This is the practical improvement over the Wald interval, whose estimated standard error is \(\sqrt{\hat p(1-\hat p)/n}\). At \(\hat p=0\) or \(1\), that estimated standard error is zero, producing a degenerate interval. Wilson uses the candidate parameter \(p\) in the score standard error, and inversion accounts for uncertainty about \(p\) instead of setting the uncertainty to zero merely because the observed proportion is at a boundary.

The Wilson interval is not an exact binomial interval. Its nominal confidence level comes from the score test's normal approximation, so actual coverage can differ from the nominal level, particularly for small samples. Nevertheless, the boundary endpoints are mathematically well-defined through closure, and the resulting interval avoids impossible values below zero or above one.

Common exam trap: Do not plug \(p=0\) or \(p=1\) into the score statistic: its denominator is zero there. Define the score condition only for \(0<p<1\), solve for the accepted interior values, and take their closure. The resulting endpoint may equal zero or one without asserting that the score statistic is defined at that endpoint.

A Reliable Calculation Sequence

1
Check the model.
Confirm that the data are a count of successes from a fixed number of independent trials with a common success probability.
2
Identify the boundary situation.
Record \(n\) and \(x\). If \(x=0\) or \(x=n\), use the boundary formula or the general formula while interpreting its endpoints as closure points.
3
Choose the critical value.
For a two-sided level \(1-\alpha\), use \(z_{1-\alpha/2}\); for the 95% calculations here, \(z=1.96\).
4
Calculate and interpret.
Substitute into the count formula, retain enough digits during the calculation, round at the end, and interpret the interval as a procedure for the unknown population probability.
Key takeaway: Wilson intervals remain informative when the observed count is zero, all successes, or close to either boundary. At \(x=0\) and \(x=n\), the score condition applies only to interior candidate probabilities; the reported endpoints are obtained by taking the closure of its accepted set.

Check Your Understanding

For each question, use a two-sided 95% Wilson interval with \(z=1.96\) unless another value is stated. Give interval endpoints to four decimal places.

  1. A hypothetical inspection finds zero flagged items among 25 independent items. Calculate the Wilson interval for the flag probability using the boundary formula. (Answer: \([0.0000,0.1332]\))
  2. A hypothetical certification test has 30 independent candidates, and all 30 pass. Calculate the Wilson interval for the pass probability. (Answer: \([0.8865,1.0000]\))
  3. A hypothetical monitoring sample records 2 events in 100 independent trials. Calculate the Wilson interval using the count form. (Answer: \([0.0055,0.0700]\))
  4. A hypothetical quality check records 58 passes among 60 independent trials. Calculate the interval by first finding the Wilson interval for the two failures and then reflecting it. (Answer: \([0.8864,0.9908]\))
  5. A sample has \(n=16\) and \(x=1\). Using \(z=1.96\), calculate the Wilson interval and explain why its lower endpoint is positive although the estimate is small. (Answer: \([0.0111,0.2833]\); the lower endpoint is positive because the accepted score set for this interior count has a positive lower root.)
Clinical Biostats