Section 11.18

Confidence interval

Definition

A confidence interval is a range computed from data by a rule designed so that, over many repetitions of the data collection, a stated fraction of the computed ranges would contain the true value of an unknown fixed quantity, such as a population mean. That fraction is the confidence level, often 95%. The true value stays fixed; the interval varies from sample to sample. The level describes the rule, not one computed interval, and holds only if the data arise as the rule assumes, for example as independent draws.

The idea

Four request times average 10 milliseconds. The true mean of the process that produced them is unknown, and the single number 10 gives no sense of how far off it may be. A confidence interval adds a range with a guarantee. The guarantee cannot be about this one range, because the true mean is a fixed number that either lies inside it or does not. It is a guarantee about the method: used again and again on fresh data, the method captures the true value in 95% of uses.

Ring toss is a fair picture. A player rings a fixed peg on 95% of throws. Before a throw, the chance of a ring is 95%; after it, the ring is either around the peg or not. The peg is the true value and stays still; the ring is the interval, which lands somewhere new with every sample. The picture stops being accurate in two respects: the true value, unlike the peg, is never seen, and the interval’s 95% holds only if the assumptions about the data are true.

How it works

The simplest case shows where the rule comes from. Assume the observations are independent, follow a normal distribution (the bell-shaped distribution that many measurement errors roughly follow), and have a known standard deviation §11.14 σ\sigma.

  1. The sample mean §11.12 X‾\bar X of nn observations then follows a normal distribution centered on the true mean μ\mu, with standard error §11.15 σ/n\sigma / \sqrt n, the standard deviation of the mean across repeated samples.

  2. In any normal distribution, 95% of the probability lies within 1.96 standard deviations of the center, so with probability 0.95, X‾\bar X lands within 1.96σ/n1.96\,\sigma / \sqrt n of μ\mu.

  3. “X‾\bar X is within that distance of μ\mu” is the same event as “μ\mu is within that distance of X‾\bar X”. So with probability 0.95, the interval X‾±1.96σ/n\bar X \pm 1.96\,\sigma / \sqrt n contains μ\mu; the sign ±\pm means subtract for the lower end and add for the upper end.

  4. Insert the observed mean to get the interval. The probability 0.95 belonged to step 3, while X‾\bar X was still random.

Usually σ\sigma is unknown and is replaced by the sample standard deviation ss. That adds uncertainty, which the multiplier must absorb. It comes from Student’s t distribution with n−1n - 1 degrees of freedom instead of from the normal distribution, and it is larger than 1.96: 2.776 for n=5n = 5 and 2.045 for n=30n = 30. Other quantities and assumptions need other rules. For large samples the central limit theorem §15.45 justifies normal multipliers without normal data, a proportion has its own binomial intervals, and the bootstrap §11.19 builds intervals by resampling the data.

A hypothesis test §11.22, a procedure that decides whether data contradict a stated value, is the same calculation seen from the other side: the 95% Student t interval for a mean contains exactly those values that a two-sided t test, one that wrongly rejects a true value with probability 0.05, would not reject.

Worked example

Known σ\sigma. Four independent normal observations with σ=2\sigma = 2 milliseconds have mean 10 milliseconds. The standard error is 2/4=12 / \sqrt 4 = 1 millisecond, the margin is 1.96×1=1.961.96 \times 1 = 1.96 milliseconds, and the 95% interval runs from 10−1.96=8.0410 - 1.96 = 8.04 to 10+1.96=11.9610 + 1.96 = 11.96 milliseconds.

Unknown σ\sigma. Five durations are 8, 9, 10, 11 and 12 milliseconds. Their mean is 50/5=1050 / 5 = 10 milliseconds. The deviations −2,−1,0,1,2-2, -1, 0, 1, 2 have squares 4, 1, 0, 1 and 4, which sum to 10, so s2=10/(5−1)=2.5s^2 = 10 / (5 - 1) = 2.5 square milliseconds and s=2.5≈1.581s = \sqrt{2.5} \approx 1.581 milliseconds. The estimated standard error is 1.581/5≈1.581/2.236≈0.7071.581 / \sqrt 5 \approx 1.581 / 2.236 \approx 0.707 milliseconds. With 5−1=45 - 1 = 4 degrees of freedom the Student t multiplier for 95% is 2.776, so the margin is 2.776×0.707≈1.9632.776 \times 0.707 \approx 1.963 milliseconds, and the interval runs from about 8.037 to about 11.963 milliseconds. Using 1.96 instead of 2.776 would give the margin 1.96×0.707≈1.3861.96 \times 0.707 \approx 1.386 milliseconds, an interval that is too narrow because it ignores the uncertainty in ss.

What the 95% means. If the five-measurement experiment were repeated 1000 times on the same process, an exact 95% rule would be expected to capture the true mean in 1000×0.95=9501000 \times 0.95 = 950 of the 1000 intervals. The actual count varies, with standard deviation 1000×0.95×0.05≈6.9\sqrt{1000 \times 0.95 \times 0.05} \approx 6.9, and which intervals missed is never known.

Not a range for single values. A 95% prediction interval for one future duration from the same normal data is x‾±ts1+1/n\bar x \pm t \, s \sqrt{1 + 1/n}, where tt is the same multiplier and the factor 1+1/n\sqrt{1 + 1/n} combines the spread of one new observation with the uncertainty of the mean. Here it is 10±2.776×1.581×1+1/5≈10±4.8110 \pm 2.776 \times 1.581 \times \sqrt{1 + 1/5} \approx 10 \pm 4.81 milliseconds, from about 5.19 to about 14.81 milliseconds, much wider than the interval for the mean.

Stated precisely

Let θ\theta (read theta) be the unknown fixed quantity, let XX stand for the random data, and let L(X)L(X) and U(X)U(X) be the lower and upper ends that the rule computes from the data. Let 1−α1 - \alpha be the confidence level, so α=0.05\alpha = 0.05 for 95%. The rule gives a (1−α)(1 - \alpha) confidence interval if Prθ(L(X)≤θ≤U(X))≥1−αfor every possible value of θ,\Pr_\theta\bigl(L(X) \le \theta \le U(X)\bigr) \ge 1 - \alpha \quad \text{for every possible value of } \theta, where Prθ\Pr_\theta is the probability over random data generated with true value θ\theta. An exact rule achieves equality. An approximate rule comes close to 1−α1 - \alpha only for large samples. The probability is over the random data XX; once the data are observed, the statement contains no probability.

The Student t interval for a mean is x‾±t1−α/2,n−1sn,\bar x \pm t_{1-\alpha/2,\,n-1} \, \frac{s}{\sqrt n}, where x‾\bar x is the sample mean, ss the sample standard deviation, nn the number of observations, and t1−α/2,n−1t_{1-\alpha/2,\,n-1} the value below which the Student t distribution with n−1n - 1 degrees of freedom has probability 1−α/21 - \alpha/2. For 95%, α/2=0.025\alpha / 2 = 0.025, so the table is read at 0.975; with n=5n = 5, t0.975,4≈2.776t_{0.975,\,4} \approx 2.776. The coverage is exactly 1−α1 - \alpha if the observations are independent and identically distributed §11.5 (IID) draws from a normal distribution. Without normality it approaches 1−α1 - \alpha as nn grows, by the central limit theorem, provided the variance is finite.

Three statements are not what a 95% confidence interval means.

Limits and common mistakes

Coverage holds only when the assumptions do. Positive correlation §15.44 among measurements from a device, a session or a burst of background load can make s/ns / \sqrt n too small and the interval too narrow. The direction depends on the covariance: negatively correlated errors can instead reduce the uncertainty of the mean. Use the sampling units and dependence structure of the design.

An interval measures random error, not bias. A timer that reads 3% high gives intervals centered 3% high, and a larger sample only makes the wrong interval narrower.

Choices made after looking at the data spoil coverage. Stopping data collection as soon as the interval excludes some value, which is called optional stopping, or reporting only the most striking of many comparisons, a problem of multiple comparisons §11.26, produces intervals that miss more often than the stated 5%.

Overlap of two intervals is not a test. Two 95% intervals can overlap even when the difference between the two means is clearly nonzero, so compute an interval for the difference itself; in a paired design §11.7, where both systems were measured on the same units, it comes from the differences within each unit.

Questions answered

What does a 95% frequentist confidence level mean?

A 95% frequentist confidence level means that the rule used to compute the interval, applied to many independent repetitions of the same data collection, would produce intervals that contain the fixed true value of the quantity in 95% of the repetitions, provided the data really arise as the rule assumes. For the usual Student t interval for a mean, coverage is exact for independent draws from the same normal distribution with positive variance. With independent draws from a common nonnormal distribution of finite, positive variance, coverage approaches the target as the sample size grows. The 95% is the rule’s long-run success rate, called its coverage.

It does not mean that this particular computed interval contains the true value with probability 95%: once computed, the interval either contains the fixed value or not, and the frequentist view assigns no probability to that. Nor does it mean that 95% of the observations lie inside the interval. For example, the five durations 8, 9, 10, 11 and 12 milliseconds give the 95% Student t interval from about 8.04 to about 11.96 milliseconds for the mean; the 95% says that the method producing such intervals captures the true mean in 95 of every 100 uses in the long run.

Related entries: Standard error (§11.15), Bootstrap (§11.19), Measurement uncertainty (§11.33), Hypothesis test (§11.22), Multiple comparisons (§11.26), Central limit theorem (§15.45). Further reading: [75, 166].