Confidence Intervals for a Mean

A biologist measures cortisol levels in 18 wild deer mice. She gets a sample mean of 12.4 ng/mL. What is the true average cortisol level for the population these mice came from? The sample mean is a single number, a point estimate. But it is almost certainly not exactly right. Confidence intervals answer a more honest question. Given the scatter in this sample, what range of values is plausible for the population mean? This matters because every measurement in biology is made on a sample, never the whole population. This includes enzyme activity, clutch size, blood pressure, and leaf area. Reporting a mean alone hides how much uncertainty surrounds it. A confidence interval turns that uncertainty into a concrete, defensible range. It is built from the Standard Error of the Mean and the shape of the t-distribution. It is the single most common quantitative tool for expressing "how sure are we." This holds true in experimental biology, medicine, and ecology. The big picture is this: a sample mean varies from sample to sample. That variability can itself be estimated from the data. Once you know how much a sample mean typically bounces around, you can build a margin of error. You build it around your observed mean. Then you can state, with a chosen level of confidence, that the interval captures the population mean. The logic is subtle — the interval is not a probability statement about a fixed parameter. But the construction is mechanical and learnable. This article builds the 95% confidence interval for a mean from first principles. It covers the sampling distribution of the mean. It explains why the t-distribution replaces the normal distribution when population variance is unknown. It gives the exact formula and a worked numerical example. It also covers the classic reasoning that justified using t rather than z in small samples. This reasoning traces back to William Gosset's "Student" work at Guinness. It also flags the single most dangerous misinterpretation students make. Finally, it previews how confidence intervals connect to The Logic of Hypothesis Testing.

Key takeaways
  • A confidence interval (CI) gives a range of plausible values for a population mean, built around the sample mean.
  • The 95% CI for a mean is: sample mean ± (critical t-value) × (standard error of the mean).
  • The t-distribution, not the normal (z) distribution, is used because the population standard deviation is estimated from the sample.
  • Degrees of freedom = n − 1; smaller samples get wider intervals because t has fatter tails than z.
  • "95% confidence" describes the long-run performance of the method across repeated sampling, not the probability that one specific interval contains the true mean.
  • CIs and hypothesis tests are two views of the same inference machinery — a CI that excludes the null value corresponds to a significant test result.
The core insight

A confidence interval is a range built from sample data that, across many repeated samples, would capture the true population mean a specified percentage of the time — it quantifies precision, not certainty about any single interval.

The core idea

A confidence interval (CI) for a population mean μ is a range of values, calculated from sample data, constructed so that if the sampling procedure were repeated many times, a specified proportion of the resulting intervals — conventionally 95% — would contain the true value of μ. The sample mean, x̄, is a point estimate: a single best guess. The confidence interval is an interval estimate: it acknowledges that x̄ varies from sample to sample and expresses that variability as a range around x̄. The width of the interval is governed by the standard error of the mean (SEM = s/√n), which measures how much sample means are expected to fluctuate around μ due to random sampling. A small SEM (large sample, low variability) gives a narrow, precise interval. A large SEM (small sample, high variability) gives a wide, imprecise interval. The interval is centered on x̄ and extends outward by a margin of error: a critical value multiplied by the SEM. The critical value comes from the t-distribution rather than the standard normal (z) distribution whenever the population standard deviation σ is unknown and must be estimated from the sample as s — which is essentially always the case in real biological work. The t-distribution has heavier tails than the normal distribution, reflecting the extra uncertainty introduced by estimating σ from a finite sample. Its exact shape depends on the degrees of freedom, df = n − 1: with few data points, t has notably fatter tails than z; as n grows large, t converges to z, because s becomes a very precise estimate of σ.

Mechanism — how the interval is actually built

Step 1: Understand why the sample mean has a sampling distribution at all. Imagine repeating the mouse-cortisol study over and over, drawing a fresh sample of 18 mice each time from the same wild population. Each sample would give a slightly different mean, purely from the luck of which mice got caught. Plotted across many hypothetical repetitions, those sample means form the sampling distribution of the mean. Its standard deviation is the SEM. By the Central Limit Theorem, this sampling distribution is approximately normal (or t-shaped, once σ is estimated) even if individual mouse cortisol values are not perfectly normal, provided n is not tiny.

Step 2: Estimate the standard error from one real sample. You only get one actual sample, so σ (population SD) is unknown. You estimate it with the sample standard deviation s, and then estimate the SEM as: SEM = s / √n This is a plug-in estimate — a source of extra uncertainty on top of the sampling variability itself, which is exactly why t (not z) is needed next.

Step 3: Pick the confidence level and find the critical t-value. For a 95% CI, you need the value t<strong> such that 95% of the t-distribution with df = n − 1 lies between −t and +*t**, leaving 2.5% in each tail. This value is read from a t-table or computed with software, and it always exceeds the corresponding z-value (1.96) for finite n — the t-distribution "pays a penalty" for the added uncertainty of estimating σ.

Step 4: Compute the margin of error and build the interval. Margin of error (ME) = *t** × SEM. The 95% CI is: x̄ − ME to x̄ + ME

Step 5: Interpret correctly. The interval is a statement about the method's long-run reliability: if you repeated the whole sampling-and-computing procedure many times, 95% of the resulting intervals would contain the true μ. Any single computed interval either does or does not contain μ — there is no probability left to talk about once the numbers are in hand.

Figure
From raw data to a confidence interval: the four-step pipeline
Sample data n = 18 mice x̄ = 12.4 ng/mL s = 3.6 ng/mL Standard error SEM = s / √n = 3.6 / √18 ≈ 0.848 Critical t-value df = n − 1 = 17 95% two-tailed t* ≈ 2.110 95% CI ME = t*×SEM ≈ 1.79 10.6 to 14.2 ng/mL
Figure
Why t is wider than z: heavier tails at small df
Sampling distribution shapes z (normal), df = ∞ t, df = 5 (fatter tails, lower peak) −1.96 (z) +1.96 (z) −2.57 (t, df=5) +2.57 (t, df=5) More df → t curve converges to z curve

The evidence

Confidence intervals rest on two empirically and mathematically established pillars: the sampling distribution behavior described by the Central Limit Theorem, and the correction for small-sample uncertainty worked out by William Sealy Gosset.

The Central Limit Theorem in action. The claim that sample means follow an approximately normal (or t) distribution — even when individual measurements do not — is not an assumption taken on faith; it is repeatedly demonstrable by simulation and was rigorously proved mathematically over the 18th–20th centuries (Laplace, and later refined proofs by Lyapunov and Lindeberg). A simple, reproducible demonstration: take a wildly non-normal population — say, a skewed distribution of parasite loads per host, most hosts near zero with a long tail of heavily infected individuals — and repeatedly draw samples of size 30, computing the mean each time. Histogram those thousands of sample means: the result is strikingly bell-shaped and centered on the true population mean, with spread shrinking as √n grows. This is routinely demonstrated in statistics courses and simulation studies, and it is the empirical justification for treating the sampling distribution of x̄ as approximately normal in large samples.

Gosset's small-sample problem, and the birth of "Student's t." The historically decisive case is William Sealy Gosset's work at the Guinness brewery in Dublin in the early 1900s. Gosset needed to make inferences about the quality of barley and yeast strains from very small samples — sometimes just 3 to 4 measurements — where the normal-distribution-based (z) methods of the day gave overconfident, too-narrow intervals. He derived, and empirically tested against distributions generated from actual height and finger-measurement data (and later through explicit random-sampling experiments drawing cards to simulate samples), the exact distribution that the quantity t = (x̄ − μ) / (s/√n) follows when the population is normal and σ is estimated from a small sample. He published this in 1908 under the pseudonym "Student" (Guinness restricted publication of trade-relevant work by employees), giving tables of the distribution now called the t-distribution. His central empirical/mathematical finding: this ratio is not normally distributed for small n — it has fatter tails — and the excess spread depends predictably on degrees of freedom. This meant that using z-critical values (like 1.96) for small samples systematically understated uncertainty, producing intervals that were too narrow and "significant" results that were too easy to obtain. Gosset's correction — using the wider, df-dependent t critical values — was later placed on rigorous theoretical footing by Ronald Fisher in the 1920s, who derived the exact sampling distribution of s² and formalized degrees of freedom. Fisher's theoretical derivation matched Gosset's empirically-motivated tables, cementing the t-distribution as the correct tool whenever σ is estimated rather than known — which describes nearly all real biological data.

Simulation as ongoing verification. Modern confirmation of the whole CI machinery is itself an experiment repeatable on a laptop: simulate 10,000 samples of size n from a known population with a known mean, build a 95% CI from each sample using the t-formula, and count how many intervals actually contain the true mean. The tally consistently comes out close to 95% — this is the standard classroom and textbook demonstration (see Whitlock & Schluter's simulation exercises) that operationalizes what "95% confidence" really means: a property of the procedure, verified by repetition, not a probability attached to any one interval.

Worked examples

Example 1 — Small, asymmetric sample: enzyme activity in a rare cichlid species A researcher measures alkaline phosphatase activity (U/L) in n = 9 wild-caught individuals of a rare Lake Malawi cichlid, since larger samples are impossible to obtain ethically: Data (U/L): 142, 155, 138, 210, 149, 133, 161, 145, 158 Step 1 — sample mean: x̄ = (142+155+138+210+149+133+161+145+158)/9 = 1391/9 ≈ 154.6 U/L Step 2 — sample standard deviation: Computing deviations from 154.6 and squaring (the value 210 is a clear outlier pulling on the spread) gives s ≈ 22.9 U/L (rounded from full calculation). Step 3 — standard error: SEM = s/√n = 22.9/√9 = 22.9/3 ≈ 7.63 U/L Step 4 — degrees of freedom and critical t: df = 9 − 1 = 8. For 95% confidence, two-tailed, t* (df=8) ≈ 2.306 (notice this is much larger than z = 1.96 — the small-sample penalty is substantial here) Step 5 — margin of error and interval: ME = 2.306 × 7.63 ≈ 17.6 U/L 95% CI = 154.6 ± 17.6 = 137.0 to 172.2 U/L Interpretation: we are 95% confident, in the long-run-frequency sense, that the interval 137.0–172.2 U/L captures the true mean alkaline phosphatase activity for this cichlid population. Note how wide this is — nearly ±11% of the mean — a direct consequence of small n and one high outlier inflating s. This is a realistic and common situation in conservation physiology, where sample sizes are constrained by animal welfare and rarity.

Example 2 — Larger sample, clinical scenario: fasting glucose after a dietary intervention A clinical trial measures fasting blood glucose (mmol/L) in n = 64 patients three months after starting a low-glycemic-index diet. Reported summary statistics: x̄ = 5.62 mmol/L, s = 0.84 mmol/L. Step 1 — standard error: SEM = 0.84/√64 = 0.84/8 = 0.105 mmol/L Step 2 — degrees of freedom and critical t: df = 64 − 1 = 63. For 95% confidence, t*(df=63) ≈ 2.00 (at this sample size, t has nearly converged to z = 1.96 — the small-sample penalty has almost vanished) Step 3 — margin of error and interval: ME = 2.00 × 0.105 ≈ 0.21 mmol/L 95% CI = 5.62 ± 0.21 = 5.41 to 5.83 mmol/L Interpretation: the plausible range for true mean post-intervention fasting glucose is fairly narrow, 5.41–5.83 mmol/L, reflecting the larger sample size. A clinician comparing this to the standard "normal fasting glucose" threshold (roughly below 5.6 mmol/L for many guidelines) would note the interval straddles that boundary — illustrating that the CI itself, not just the point estimate, informs whether the intervention convincingly shifted patients into a normal range. This foreshadows the direct link between CIs and hypothesis testing: if a null hypothesized mean (say, μ₀ = 6.0 mmol/L, a pre-treatment baseline) falls outside this interval, a two-sided test at α = 0.05 would reject that null.

Common misconceptions & traps

MisconceptionWhy it's wrong
"There is a 95% probability that the true mean lies in this specific computed interval."Once numbers are plugged in, the interval is fixed; μ is fixed (though unknown). The 95% describes the procedure's long-run success rate across repeated sampling, not a probability for this one interval.
"A 95% CI means 95% of the data fall in this range."No — that describes a reference range or percentile range of individual data points, a completely different concept from a CI for the mean.
"Wider CI = worse experiment."A wide CI often just reflects small n or high natural variability (biology!), not a flawed design — though it does mean lower precision.
"If two 95% CIs overlap even slightly, the means aren't significantly different."Overlapping CIs can still correspond to a statistically significant difference between two means; the correspondence is not exact, especially with unequal sample sizes/variances.
"Use z (1.96) whenever n is 'large enough', otherwise it doesn't matter."The t-distribution is technically always the correct choice when σ is estimated from data, regardless of n; z is only a convenient large-n approximation.
"A 99% CI is 'more true' than a 95% CI."Higher confidence levels give wider, less precise intervals for the same data — there's a precision/confidence trade-off, not increasing correctness.

The scientist behind it

Origins · 1 minWilliam Sealy Gosset and how this was discovered
WS
William Sealy Gosset
1876–1937 · Chemist and statistician, Guinness Brewery, Dublin

Gosset trained in chemistry and mathematics at Oxford before joining Guinness in 1899 as a brewer, where he confronted a problem industrial statistics had not yet solved: how to draw reliable conclusions from very small samples of barley, hops, and yeast — often just a handful of measurements from limited experimental batches. Existing statistical theory assumed large samples where the normal distribution was a safe approximation; Gosset's data rarely offered that luxury. Working largely independently, he derived the exact small-sample distribution of the standardized mean when the population standard deviation must itself be estimated, testing his mathematics empirically against real anthropometric data. Guinness's policy barred employees from publishing company-related work under their own names (to protect trade secrets), so Gosset published his landmark 1908 paper in Biometrika under the pseudonym "Student" — hence "Student's t-distribution." His correction quietly and permanently reshaped how science handles uncertainty in small samples, from agricultural field trials to modern clinical pilot studies.

History
- 1899 — Gosset joins Guinness as a brewer, encountering small-sample inference problems in practice.
- 1908 — Gosset publishes "The Probable Error of a Mean" in Biometrika under the pseudonym "Student," introducing the t-distribution.
- 1920s — Ronald Fisher rigorously derives the exact sampling distribution underlying Gosset's t, formalizes "degrees of freedom," and popularizes the method in Statistical Methods for Research Workers (1925).
- 1934–1937 — Jerzy Neyman develops the formal theory of confidence intervals as a general framework for interval estimation, distinct from Fisher's fiducial approach.
- Mid-20th century onward — t-based confidence intervals become standard practice across biology, medicine, and agriculture as computing and tables make them routinely accessible.

Where this matters today

Clinical trials and drug approval. Regulatory bodies (FDA, EMA) require confidence intervals, not just p-values, for treatment effects — e.g., the 95% CI for the mean reduction in blood pressure from a new drug tells clinicians the plausible range of real-world benefit, which matters for weighing against side effects even when a result is "statistically significant."

Conservation biology and small population monitoring. Endangered species studies routinely work with tiny samples (a handful of tagged individuals, a few surviving nests), making the t-distribution's small-sample correction essential — using z instead of t in such studies would understate uncertainty and risk overconfident management decisions.

Agricultural field trials. Ironically returning to Gosset's original context, modern crop yield trials still report CIs for mean yield differences between varieties or fertilizer treatments, guiding real-world planting decisions across thousands of hectares.

Ecological and physiological reference ranges. Establishing "normal" ranges for physiological variables (body temperature, cortisol baselines, growth rates) in a species requires CIs around means from field or lab samples, feeding directly into veterinary diagnostics and wildlife health assessments.

Reproducibility and meta-analysis. Confidence intervals are the standard input for meta-analyses that pool results across many small biological studies — forest plots (visual summaries of CIs from multiple studies) are a direct, ubiquitous application built entirely on this machinery.

Ask the tutor: How would this confidence interval formula change if I wanted to compare two independent sample means instead of estimating just one?

Why do we use n − 1 (degrees of freedom) instead of n when estimating the standard deviation?

Estimating the sample standard deviation requires first calculating the sample mean, x̄, which uses up one "degree of freedom" from the data. Once x̄ is fixed, only n − 1 of the n deviations from that mean are free to vary — the last one is mathematically determined by the requirement that all deviations sum to zero. Dividing the sum of squared deviations by n − 1 (rather than n) corrects a systematic downward bias that would otherwise occur, giving an unbiased estimate of the population variance. This n − 1 also becomes the degrees of freedom parameter that determines exactly which t-distribution shape to use when building the confidence interval.

Does a 95% CI mean 95% of my data points fall inside it?

No — this confuses two very different kinds of interval. A confidence interval for the mean describes uncertainty about the population parameter (μ), built from the standard error, and it typically covers only a narrow range around x̄. A reference range or prediction interval describing where most individual data points fall is a much wider interval based on the standard deviation (s) itself, not the standard error. Individual measurements are far more variable than the mean of many measurements, so conflating the two badly underestimates the spread of raw data or badly overestimates the uncertainty in the mean, depending on which direction the error runs.

How does sample size affect the width of a confidence interval, and why?

Increasing sample size narrows the CI through two compounding effects. First, the standard error (s/√n) shrinks as n grows, since averaging over more observations reduces sampling noise — but only at a rate of √n, so quadrupling n only halves the SEM. Second, the critical t-value itself shrinks toward the z-value of 1.96 as degrees of freedom increase, because larger samples make s a more reliable estimate of σ, reducing the extra uncertainty penalty. Both effects push in the same direction, so intervals shrink noticeably from very small samples to moderate ones, then shrink more slowly as n climbs into the hundreds.

Can a confidence interval be used instead of a hypothesis test?

Yes, and increasingly biologists are encouraged to report both, or CIs alone, because they carry more information than a bare p-value. If a 95% CI for a mean excludes a hypothesized null value (say, zero difference, or a historical baseline), that is mathematically equivalent to rejecting the corresponding null hypothesis at α = 0.05 in a two-tailed test. But the CI additionally shows the plausible magnitude of the effect, which matters for judging real-world or biological importance — a topic developed further under Statistical vs Biological Importance and formalized in The Logic of Hypothesis Testing.

What assumptions does the t-based confidence interval for a mean rely on?

The classical derivation assumes the underlying population is approximately normally distributed, or that the sample size is large enough for the Central Limit Theorem to make the sampling distribution of x̄ approximately normal regardless of the population's shape. It also assumes observations are independent — no natural clustering, repeated measures on the same individual without adjustment, or non-random sampling that would violate this. For strongly skewed data with small n, or non-independent samples (e.g., multiple measurements per animal treated as separate data points), the standard t-interval can be unreliable, and alternatives (transformation, bootstrap resampling, mixed models) are often preferred.

What happens to the confidence interval if I choose 99% confidence instead of 95%?

Raising the confidence level widens the interval, because you are demanding that the procedure succeed more often across hypothetical repetitions, which requires casting a wider net around the sample mean. Concretely, the critical t-value increases — for example, moving from roughly t ≈ 2.0–2.3 (95%, depending on df) to a noticeably larger value (often around 2.6–3.5 for the same df) at 99% confidence. This illustrates the fundamental trade-off in interval estimation: higher confidence buys protection against missing the true mean, but costs precision by producing a less informative, wider range.

Why did Gosset need a new distribution instead of just using the normal distribution with estimated s?

When sample size is small, replacing the unknown population standard deviation σ with the sample estimate s introduces its own random error on top of the sampling error already present in x̄. Gosset showed that the resulting standardized statistic, (x̄ − μ)/(s/√n), does not follow a normal distribution when n is small — it has heavier tails, reflecting the added uncertainty from estimating s itself from limited data. Using normal-based (z) critical values in this situation systematically understates the true uncertainty, producing intervals that are falsely narrow and overconfident — a serious risk in small brewery trials, and equally in modern studies with limited biological samples.

Before this

Where this leads