Probability and inferential statistics
A confidence interval for a mean
How precisely do five measurements estimate a population mean?
Population and data
Estimate the mean of the population that generated the sample. An interval for the next individual observation answers a different question: individuals can vary considerably even when their population mean is estimated precisely.
Five independent observations are 8, 9, 10, 11 and 12. Assume a random sample from a normal population with unknown variance. The target is the population mean.
| Observation | Deviation from 10 | Squared deviation |
|---|---|---|
| 8 | −2 | 4 |
| 9 | −1 | 1 |
| 10 | 0 | 0 |
| 11 | 1 | 1 |
| 12 | 2 | 4 |
Notation
- Random measurement i and its observed value.
- Population mean and variance.
- Sample mean and standard deviation before sampling; their observed values after sampling.
- Quantile with cumulative probability q and ν degrees of freedom.
Derivation
For independent, identically distributed normal measurements with positive variance, this probability is exact for every population mean and variance. Before sampling the endpoints vary and the mean is fixed. After sampling the two endpoints are numbers. [1][2]
For independent measurements with common variance, variances add. Dividing the sum by n divides its variance by n squared. This is where the square root of n in the standard error comes from.
Under normal sampling the statistic on the right has a known distribution. Place its middle 95% between the two t quantiles and solve the inequalities for the unknown mean. This inversion produces the interval below. [1][2]
Estimate the variance of individual measurements, then the standard error of their average.
Estimating the variance leaves four degrees of freedom. Use the 97.5th percentile for a two-sided 95% interval.
R analysis
Download the complete R scriptx <- 8:12
round(as.numeric(t.test(x)$conf.int), 3)R output
[1] 8.037 11.963
Across repeated samples under these assumptions, 95% of intervals constructed this way cover the population mean. The interval describes uncertainty about the mean.
What happens when a single observation changes?
Replace 12 by 20. Recompute the center and half-width separately to see which moves most.
summarize <- function(x) {
se <- sd(x) / sqrt(length(x))
half <- qt(.975, length(x) - 1) * se
c(mean = mean(x), SE = se, lower = mean(x)-half, upper = mean(x)+half)
}
round(rbind(original = summarize(8:12),
changed = summarize(c(8:11, 20))), 3)R output
mean SE lower upper original 10.0 0.707 8.037 11.963 changed 11.6 2.159 5.606 17.594
The new value moves the mean by 1.6 and also increases the estimated spread. The interval therefore widens as well as shifting. Merely translating every observation would shift the center without changing its width. [1]
Try a variation
What happens if every measurement increases by 2?
Reveal the explanation
Both endpoints increase by 2. The sample deviations and interval width stay the same.
References
The datasets and calculations are teaching examples created for this tutorial. The sources below explain the methods used.
- Illowsky B, Dean S. Introductory Statistics. 2nd ed. OpenStax, 2023. §8.2.
The one-sample t interval when population variance is unknown.
- Student. The probable error of a mean. Biometrika. 1908;6:1–25.
Original development of small-sample inference for a mean with estimated variance.