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 .
The sample mean §11.12 of observations then follows a normal distribution centered on the true mean , with standard error §11.15 , the standard deviation of the mean across repeated samples.
In any normal distribution, 95% of the probability lies within 1.96 standard deviations of the center, so with probability 0.95, lands within of .
“ is within that distance of ” is the same event as “ is within that distance of ”. So with probability 0.95, the interval contains ; the sign means subtract for the lower end and add for the upper end.
Insert the observed mean to get the interval. The probability 0.95 belonged to step 3, while was still random.
Usually is unknown and is replaced by the sample standard deviation . That adds uncertainty, which the multiplier must absorb. It comes from Student’s t distribution with degrees of freedom instead of from the normal distribution, and it is larger than 1.96: 2.776 for and 2.045 for . 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 . Four independent normal observations with milliseconds have mean 10 milliseconds. The standard error is millisecond, the margin is milliseconds, and the 95% interval runs from to milliseconds.
Unknown . Five durations are 8, 9, 10, 11 and 12 milliseconds. Their mean is milliseconds. The deviations have squares 4, 1, 0, 1 and 4, which sum to 10, so square milliseconds and milliseconds. The estimated standard error is milliseconds. With degrees of freedom the Student t multiplier for 95% is 2.776, so the margin is 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 milliseconds, an interval that is too narrow because it ignores the uncertainty in .
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 of the 1000 intervals. The actual count varies, with standard deviation , 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 , where is the same multiplier and the factor combines the spread of one new observation with the uncertainty of the mean. Here it is milliseconds, from about 5.19 to about 14.81 milliseconds, much wider than the interval for the mean.
Stated precisely
Let (read theta) be the unknown fixed quantity, let stand for the random data, and let and be the lower and upper ends that the rule computes from the data. Let be the confidence level, so for 95%. The rule gives a confidence interval if where is the probability over random data generated with true value . An exact rule achieves equality. An approximate rule comes close to only for large samples. The probability is over the random data ; once the data are observed, the statement contains no probability.
The Student t interval for a mean is where is the sample mean, the sample standard deviation, the number of observations, and the value below which the Student t distribution with degrees of freedom has probability . For 95%, , so the table is read at 0.975; with , . The coverage is exactly if the observations are independent and identically distributed §11.5 (IID) draws from a normal distribution. Without normality it approaches as grows, by the central limit theorem, provided the variance is finite.
Three statements are not what a 95% confidence interval means.
“The true value lies in this computed interval with probability 95%.” In the frequentist view, in which probability describes how often outcomes occur over repetitions, the true value is fixed and the computed interval either contains it or does not. A Bayesian credible interval does give such a probability, but it is computed by combining the data with a prior distribution, a stated belief about the value before seeing the data.
“95% of the observations lie in the interval.” That describes a prediction interval, which the worked example shows to be much wider.
“A repeated experiment will give a mean inside this interval with probability 95%.” In the known- normal case that probability, computed before either experiment, is , where is the cumulative distribution function of the standard normal distribution; it is lower because both means vary.
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 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].