All lab tutorials

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.

Working data
ObservationDeviation from 10Squared deviation
8−24
9−11
1000
1111
1224

Notation

Xi,xiX_i, x_i
Random measurement i and its observed value.
μ,σ2\mu,\sigma^2
Population mean and variance.
Xˉ,S;xˉ,s\bar X,S;\quad\bar x,s
Sample mean and standard deviation before sampling; their observed values after sampling.
tq,νt_{q,\nu}
Quantile with cumulative probability q and ν degrees of freedom.

Derivation

Pμ,σ ⁣(−t0.975,n−1≤Xˉ−μS/n≤t0.975,n−1)=0.95P_{\mu,\sigma}\!\left(-t_{0.975,n-1}\leq\frac{\bar X-\mu}{S/\sqrt n}\leq t_{0.975,n-1}\right)=0.95

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.

Var⁡(Xˉ)=nσ2n2,T=Xˉ−μS/n∼tn−1\operatorname{Var}(\bar X)=\frac{n\sigma^2}{n^2},\qquad T=\frac{\bar X-\mu}{S/\sqrt n}\sim t_{n-1}

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.

s2=∑i(xi−xˉ)2n−1=104,SE(xˉ)=s5=0.7071s^2=\frac{\sum_i(x_i-\bar x)^2}{n-1}=\frac{10}{4},\quad SE(\bar x)=\frac{s}{\sqrt{5}}=0.7071

Estimating the variance leaves four degrees of freedom. Use the 97.5th percentile for a two-sided 95% interval.

xˉ±t0.975,4 SE=10±2.7764(0.7071)\bar x\pm t_{0.975,4}\,SE=10\pm 2.7764(0.7071)

R analysis

Download the complete R script
x <- 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.

  1. Illowsky B, Dean S. Introductory Statistics. 2nd ed. OpenStax, 2023. §8.2.

    The one-sample t interval when population variance is unknown.

  2. Student. The probable error of a mean. Biometrika. 1908;6:1–25.

    Original development of small-sample inference for a mean with estimated variance.