Biostatistics • Hypothesis Testing

One & Two-Sample t-Tests — One-sample and two-sample t-tests (independent samples)

Inferring population means from small samples when the population standard deviation is unknown.

A scatter plot connecting biological data with a DNA strand and health signal.
Inside this lesson 10 sections 5 questions 8 figures

SECTION 1

Historical Context & Motivation

Modern biostatistics owes much of its inferential machinery to a practical problem in early twentieth-century industry: how to draw reliable conclusions about a population mean when only a handful of observations are available and the population variance is unknown. Before the development of the t-test, researchers relied on the normal (z) distribution for inference, which requires either large samples or knowledge of the population standard deviation — luxuries seldom available in biological or clinical research. The gap between what the z-test demands and what experimenters actually possess motivated a quieter revolution in statistics, one that unfolded not in a university lecture hall but in a brewery.

1908 • Student's t-Distribution

William Sealy Gosset, a chemist at the Guinness Brewery in Dublin, published The Probable Error of a Mean under the pseudonym 'Student.' Working with small batches of barley, Gosset derived a distribution that accounts for the extra uncertainty introduced when the sample standard deviation is used in place of the unknown population value.

1925 • Fisher's Formalization

Ronald A. Fisher refined Gosset's work, introduced the concept of degrees of freedom, and embedded the t-distribution within the broader framework of hypothesis testing and analysis of variance.

1937 • Welch's Unequal-Variance Extension

Bernard L. Welch proposed an approximate t-test that relaxes the assumption of equal population variances between two groups, yielding the widely used Welch's t-test and its associated Satterthwaite approximation for degrees of freedom.

1950s–present • Ubiquity in Biomedical Research

With the rise of clinical trials, epidemiology, and genomics, the one-sample and two-sample t-tests became foundational tools for comparing treatment means, validating biomarkers, and evaluating drug efficacy across the biomedical sciences.

The central question the t-test addresses remains as relevant today as it was in 1908: given a sample of limited size from a population whose variance must be estimated, can we draw defensible conclusions about the population mean or about whether two population means differ? Answering that question requires a distribution that is heavier-tailed than the normal — one that honestly reflects our uncertainty about the spread of the data.

SECTION 2

Core Principles & Definitions

The t-test family rests on several interconnected ideas that distinguish it from large-sample z-tests. Understanding these foundational principles is essential before diving into formulas, because the logic of hypothesis testing — formulating null and alternative hypotheses, computing a test statistic, comparing it to a reference distribution, and drawing a conclusion — is the same regardless of whether you are working with one sample or two.

1

The t-Distribution

A symmetric, bell-shaped distribution that is heavier-tailed than the standard normal. Its shape depends on degrees of freedom (df); as df increases, it converges to the z-distribution.
2

Standard Error of the Mean

The standard error (SE) quantifies sampling variability: SE = s / √n. It replaces σ / √n when the population standard deviation σ is unknown, using the sample standard deviation s instead.
3

Null & Alternative Hypotheses

The null hypothesis (H₀) posits no effect or no difference. The alternative hypothesis (H₁) claims an effect exists. Tests may be two-tailed (≠) or one-tailed (< or >).
4

Assumptions

Both one-sample and two-sample t-tests assume that the underlying data are approximately normally distributed (or n is large enough for the CLT to apply) and that observations are independent. The pooled two-sample test additionally assumes equal population variances.
5

p-Value & Decision Rule

The p-value is the probability of observing a test statistic at least as extreme as the computed value, assuming H₀ is true. If p < α (commonly 0.05), we reject H₀.
✦

KEY TAKEAWAY

Think of the t-distribution as a 'humble' version of the normal curve. When you estimate the population variance from a small sample, you are less certain about the true spread, so the distribution compensates by assigning more probability to extreme values — its tails are fatter. As your sample grows, your estimate of variance improves, the tails slim down, and the t-distribution becomes nearly indistinguishable from the z-distribution. This is analogous to an engineer designing a bridge: with fewer soil samples, safety margins (analogous to wider tails) must be larger to account for the unknown.

SECTION 3

Visual Explanation — The t-Distribution & Test Logic

t-Distribution vs. Standard Normal (z)0−2−112−33t (or z) valueHeavier tail (t, df=5)← tail thinner (z)Standard Normal (z)t-distribution (df = 5)
The cyan curve represents a t-distribution with 5 degrees of freedom, while the violet curve is the standard normal (z) distribution. Notice that the t-distribution has heavier tails — more probability mass in the extremes — reflecting the additional uncertainty from estimating the population standard deviation. As the degrees of freedom increase (i.e., as the sample size grows), the t-distribution converges toward the z-distribution.

The diagram above illustrates the fundamental difference between the z- and t-distributions. In a one-sample t-test, you compute a test statistic that measures how many estimated standard errors the sample mean lies from a hypothesized population mean, and you compare that statistic to the t-distribution with n − 1 degrees of freedom. In a two-sample t-test, the logic is identical except the test statistic now measures the distance between two sample means relative to the pooled (or unpooled) standard error, and the degrees of freedom depend on both sample sizes. In both cases, if the computed t-value falls far enough into the tails — beyond a critical value determined by the chosen significance level α — you reject the null hypothesis.

SECTION 4

Mathematical Framework

One-Sample t-Test

The one-sample t-test evaluates whether the mean of a single population differs from a specified value μ₀. It is appropriate when the population standard deviation σ is unknown and must be estimated by the sample standard deviation s.

ONE-SAMPLE t-STATISTIC

t=(xˉ−μ0)/(s/√n)t = (x̄ − μ₀) / (s / √n)

where x̄ = sample mean, μ₀ = hypothesized population mean, s = sample standard deviation, n = sample size. Degrees of freedom: df = n − 1.

Two-Sample t-Test (Independent Samples, Equal Variances — Pooled)

When comparing the means of two independent groups and assuming that both populations share a common variance, we first compute a pooled variance that combines information from both samples, weighted by their respective degrees of freedom.

POOLED VARIANCE

sp2=[(n1−1)s12+(n2−1)s22]/(n1+n2−2)s²ₚ = [(n₁ − 1)s₁² + (n₂ − 1)s₂²] / (n₁ + n₂ − 2)

where s₁² and s₂² are the sample variances for groups 1 and 2, and n₁, n₂ are the respective sample sizes.

TWO-SAMPLE t-STATISTIC (POOLED)

t=(xˉ1−xˉ2)/√[sp2×(1/n1+1/n2)]t = (x̄₁ − x̄₂) / √[s²ₚ × (1/n₁ + 1/n₂)]

Degrees of freedom: df = n₁ + n₂ − 2. Under H₀, the difference (x̄₁ − x̄₂) is compared to 0 (or another hypothesized difference δ₀).

Welch's t-Test (Unequal Variances)

WELCH'S t-STATISTIC

t=(xˉ1−xˉ2)/√(s12/n1+s22/n2)t = (x̄₁ − x̄₂) / √(s₁²/n₁ + s₂²/n₂)

The degrees of freedom are approximated via the Satterthwaite formula: df ≈ (s₁²/n₁ + s₂²/n₂)² / [(s₁²/n₁)²/(n₁−1) + (s₂²/n₂)²/(n₂−1)]. This test does not assume equal population variances and is generally recommended as the default two-sample procedure.

💡

When to Pool?

In practice, many statisticians recommend using Welch's t-test by default because it performs well even when variances are equal, and it protects against inflated Type I error rates when they are not. The pooled test is appropriate only when you have strong a priori reasons (or Levene's test confirmation) to believe σ₁² = σ₂².

SECTION 5

Choosing the Right t-Test — Decision Flowchart

Selecting the correct t-test variant depends on three key questions: (1) Are you comparing a single sample to a known value, or comparing two independent groups? (2) If two groups, are the samples independent or paired? (3) If independent, can you assume equal variances? The following diagram traces the decision logic.

t-Test Selection FlowchartHow many samples?OneTwoOne-Sample t-TestAre samples independent?No (paired)YesPaired t-Test(beyond this lesson's scope)Equal variances?YesNo / UnsurePooled (Student's)df = n₁ + n₂ − 2Welch's t-Testdf ≈ Satterthwaitedf = n − 1This lesson covers the pink, violet/cyan branches (one-sample and independent two-sample tests)
Start at the top and follow the branches. This lesson covers the one-sample t-test (left branch) and the independent two-sample t-tests (right branch, splitting into pooled and Welch's versions). The paired t-test (green box) is addressed in a separate lesson.

Before conducting any t-test, it is good practice to inspect the data for approximate normality (e.g., Q-Q plots, Shapiro-Wilk test) and, in the two-sample case, to assess the equality of variances (e.g., Levene's test or an F-test). If the normality assumption is severely violated and the sample is small, nonparametric alternatives such as the Wilcoxon signed-rank test (one-sample) or the Mann-Whitney U test (two-sample) may be more appropriate. However, the t-test is reasonably robust to moderate departures from normality, especially when sample sizes exceed 30 or so, thanks to the Central Limit Theorem.

SECTION 6

Worked Examples

Example A: One-Sample t-Test

A clinical dietitian hypothesizes that the mean serum cholesterol level in a patient population differs from the national average of 200 mg/dL. She draws a random sample of n = 16 patients and obtains x̄ = 214 mg/dL with s = 28 mg/dL. Test her hypothesis at α = 0.05 (two-tailed).

One-Sample t-Test — Serum Cholesterol

  1. 1

    Step 1 — State Hypotheses

    H₀: μ = 200 mg/dL (population mean equals the national average). H₁: μ ≠ 200 mg/dL (population mean differs from the national average).
  2. 2

    Step 2 — Compute the Standard Error

    SE = s / √n = 28 / √16 = 28 / 4 = 7.0 mg/dL.
    SE = 7.0 mg/dL
  3. 3

    Step 3 — Compute the t-Statistic

    t = (x̄ − μ₀) / SE = (214 − 200) / 7.0 = 14 / 7 = 2.00.
    t = 2.00
  4. 4

    Step 4 — Determine Degrees of Freedom & Critical Value

    df = n − 1 = 15. For a two-tailed test at α = 0.05, the critical values from a t-table are approximately tcrit = ±2.131.
    t_crit = ±2.131
  5. 5

    Step 5 — Decision

    Because |t| = 2.00 < 2.131, the test statistic does not fall in the rejection region. Additionally, the two-tailed p-value ≈ 0.064, which exceeds α = 0.05.
    Fail to reject H₀. Insufficient evidence at α = 0.05 to conclude that the mean serum cholesterol in this population differs from 200 mg/dL.

Example B: Independent Two-Sample t-Test (Pooled)

A pharmacologist compares the mean reduction in systolic blood pressure (mmHg) between a new antihypertensive drug (Group 1, n₁ = 12, x̄₁ = 15.2, s₁ = 4.0) and a placebo (Group 2, n₂ = 10, x̄₂ = 10.8, s₂ = 3.6). Assume equal variances. Test at α = 0.05 (two-tailed).

Two-Sample Pooled t-Test — Blood Pressure Reduction

  1. 1

    Step 1 — State Hypotheses

    H₀: μ₁ − μ₂ = 0 (no difference in mean BP reduction). H₁: μ₁ − μ₂ ≠ 0 (the drug produces a different mean reduction than placebo).
  2. 2

    Step 2 — Compute the Pooled Variance

    s²ₚ = [(12 − 1)(4.0²) + (10 − 1)(3.6²)] / (12 + 10 − 2) = [11 × 16 + 9 × 12.96] / 20 = [176 + 116.64] / 20 = 292.64 / 20 = 14.632.
    s²ₚ = 14.632, so sₚ ≈ 3.825
  3. 3

    Step 3 — Compute the Standard Error of the Difference

    SE = sₚ × √(1/n₁ + 1/n₂) = 3.825 × √(1/12 + 1/10) = 3.825 × √(0.0833 + 0.1000) = 3.825 × √0.1833 = 3.825 × 0.4282 ≈ 1.638.
    SE ≈ 1.638 mmHg
  4. 4

    Step 4 — Compute the t-Statistic

    t = (x̄₁ − x̄₂) / SE = (15.2 − 10.8) / 1.638 = 4.4 / 1.638 ≈ 2.686.
    t ≈ 2.686
  5. 5

    Step 5 — Degrees of Freedom & Decision

    df = n₁ + n₂ − 2 = 20. The critical value at α = 0.05 (two-tailed) with 20 df is ±2.086. Since |t| = 2.686 > 2.086, we reject H₀. The p-value ≈ 0.014.
    Reject H₀. At α = 0.05, there is statistically significant evidence that the drug reduces systolic BP more than the placebo.

SECTION 7

Strengths, Limitations & Common Pitfalls

AspectStrengthsLimitations
Sample sizeValid for small samples (n < 30) when normality holds; no need for large nWith very small n (e.g., n < 5), even minor deviations from normality can distort results
RobustnessModerately robust to non-normality when n is large (Central Limit Theorem)Sensitive to heavy-tailed distributions and outliers, which inflate s and reduce power
Variance assumptionWelch's variant removes the equal-variance requirementThe pooled version can produce misleading results if σ₁² ≠ σ₂²
Number of groupsSimple interpretation and widespread understandingComparing more than two groups requires ANOVA; multiple t-tests inflate Type I error
Effect communicationEasy to supplement with confidence intervals and effect sizes (Cohen's d)A significant p-value does not convey the magnitude or clinical relevance of the effect

Comparison of strengths and limitations of the t-test framework

⚠️

KEY TAKEAWAY

Statistical significance is not the same as practical significance. A t-test might detect a 2 mg/dL difference in cholesterol with p < 0.05 if the sample is large enough, yet such a tiny difference may be clinically irrelevant. Always report a confidence interval alongside your p-value, and consider calculating Cohen's d (the difference in means divided by the pooled standard deviation) to quantify the effect size. Think of it this way: the p-value tells you whether an effect likely exists, but Cohen's d tells you how large that effect is — and in biomedical research, it is the size that determines whether you change clinical practice.

SECTION 8

Connections to Advanced Theory

The t-test is not an isolated procedure; it sits at the crossroads of several more general frameworks. Understanding how it relates to ANOVA, linear regression, and nonparametric methods will deepen your statistical reasoning and prepare you for multivariate analyses encountered in advanced biostatistics coursework.

Featuret-TestAdvanced Extension
Number of groups1 or 2 groupsANOVA (≥ 2 groups); the two-sample t-test is a special case of one-way ANOVA with k = 2 (F = t²)
Model frameworkCompares means directlyLinear regression with a single binary predictor yields the same t-statistic and p-value as the two-sample t-test
Normality requiredYes (approximately)Nonparametric alternatives: Wilcoxon rank-sum (two-sample) or signed-rank (one-sample) when normality is violated
Multiple testingSingle comparisonBonferroni, Holm, or FDR corrections needed when performing many t-tests simultaneously (e.g., genomics)
Bayesian analogFrequentist frameworkBayesian t-tests assign prior distributions to μ and σ², yielding posterior probabilities and Bayes factors

t-Test vs. advanced statistical methods

A particularly elegant connection is the equivalence between the two-sample t-test and simple linear regression. If you code group membership as a binary variable (e.g., 0 for placebo, 1 for treatment) and regress the outcome on this indicator, the slope coefficient's t-statistic is identical to the independent-samples t-statistic. This insight generalizes: once you move to ANCOVA or multiple regression, you are effectively performing adjusted t-tests that control for covariates. Mastering the t-test therefore builds the conceptual scaffolding for the general linear model.

SECTION 9

Practice Problems

Question 1: CONCEPTUAL

Explain why the t-distribution has heavier tails than the standard normal distribution. Under what conditions does the t-distribution approach the z-distribution?
Show answer
The t-distribution is heavier-tailed because the test statistic involves the sample standard deviation s in the denominator rather than the known population standard deviation σ. Since s is itself a random variable that fluctuates from sample to sample, the resulting ratio has more variability than a z-score, pushing more probability into the tails. As the sample size n increases, s converges to σ by the law of large numbers, so the degrees of freedom (df = n − 1) grow and the t-distribution converges to the standard normal. In practice, when df exceeds approximately 30, the two distributions are nearly indistinguishable.

Question 2: BASIC CALCULATION

A researcher measures the resting heart rate (bpm) of n = 25 healthy adults and obtains x̄ = 76.4 bpm with s = 8.0 bpm. Test whether the population mean differs from the textbook value of 72 bpm at α = 0.05 (two-tailed). Compute the t-statistic and state your conclusion.
Show answer
SE = s / √n = 8.0 / √25 = 8.0 / 5 = 1.6 bpm. The t-statistic is t = (76.4 − 72) / 1.6 = 4.4 / 1.6 = 2.75. With df = 24, the two-tailed critical value at α = 0.05 is approximately ±2.064. Since |t| = 2.75 > 2.064, we reject H₀. The p-value is approximately 0.011. There is statistically significant evidence at the 0.05 level that the mean resting heart rate in this population differs from 72 bpm.

Question 3: INTERMEDIATE

Two independent groups of patients receive different rehabilitation protocols after knee surgery. Group A (n₁ = 15, x̄₁ = 38 degrees, s₁ = 6) and Group B (n₂ = 18, x̄₂ = 33 degrees, s₂ = 7) are assessed on range-of-motion improvement. Assuming equal variances, conduct a pooled two-sample t-test at α = 0.05 (two-tailed). Report the pooled standard deviation, t-statistic, degrees of freedom, and your conclusion.
Show answer
First, compute the pooled variance: s²ₚ = [(15−1)(36) + (18−1)(49)] / (15+18−2) = [504 + 833] / 31 = 1337 / 31 = 43.129, so sₚ ≈ 6.567. The standard error of the difference is SE = 6.567 × √(1/15 + 1/18) = 6.567 × √(0.0667 + 0.0556) = 6.567 × √0.1222 = 6.567 × 0.3496 ≈ 2.296. The t-statistic is t = (38 − 33) / 2.296 = 5 / 2.296 ≈ 2.178. With df = 31, the critical value at α = 0.05 (two-tailed) is approximately ±2.040. Since 2.178 > 2.040, we reject H₀ (p ≈ 0.037). There is significant evidence that the two rehabilitation protocols produce different mean improvements in range of motion.

Question 4: APPLIED

An epidemiologist compares fasting blood glucose (mg/dL) between a sample of urban residents (n₁ = 40, x̄₁ = 102, s₁ = 14) and rural residents (n₂ = 35, x̄₂ = 96, s₂ = 10). She suspects unequal variances. Perform Welch's t-test at α = 0.05 (two-tailed). Compute the Satterthwaite-approximated degrees of freedom and interpret the result in a public health context.
Show answer
SE = √(s₁²/n₁ + s₂²/n₂) = √(196/40 + 100/35) = √(4.9 + 2.857) = √7.757 ≈ 2.785. The t-statistic is t = (102 − 96) / 2.785 = 6 / 2.785 ≈ 2.154. For the Satterthwaite df: numerator = (4.9 + 2.857)² = (7.757)² = 60.17; denominator = (4.9)²/(40−1) + (2.857)²/(35−1) = 24.01/39 + 8.163/34 = 0.6156 + 0.2401 = 0.8557; df ≈ 60.17 / 0.8557 ≈ 70.3, which we round down to 70. The critical value at df = 70, α = 0.05 (two-tailed) is approximately ±1.994. Since |t| = 2.154 > 1.994, we reject H₀ (p ≈ 0.035). In a public health context, urban residents show significantly higher fasting glucose on average, suggesting that lifestyle or dietary differences associated with urbanization may warrant targeted screening programs.

Question 5: CRITICAL THINKING

A colleague performs 10 independent two-sample t-tests across different biomarkers, each at α = 0.05, and finds that exactly one yields p < 0.05. She claims this biomarker significantly differs between groups. Critically evaluate this claim. What is the probability of obtaining at least one false positive among 10 tests under the global null hypothesis? Propose a correction strategy and discuss how it affects statistical power.
Show answer
Under the global null hypothesis (no true differences for any biomarker), each test has a 5% chance of a false positive. The probability of at least one false positive across 10 independent tests is 1 − (1 − 0.05)¹⁰ = 1 − 0.95¹⁰ ≈ 1 − 0.5987 ≈ 0.401, or roughly 40%. Therefore, finding one nominally significant result among 10 tests is entirely consistent with chance and does not constitute strong evidence. A Bonferroni correction would set the per-test significance level to α/10 = 0.005, controlling the family-wise error rate at 0.05. This is conservative, however, and reduces power — that is, the probability of detecting truly different biomarkers decreases. A less conservative alternative is the Holm step-down procedure, which orders p-values and applies progressively less strict thresholds, maintaining FWER control while recovering some power. In large-scale biomarker studies, the Benjamini-Hochberg procedure, which controls the false discovery rate (FDR) rather than the FWER, offers an even better power-preservation trade-off.

SUMMARY

Lesson Summary

Summary

The one-sample t-test evaluates whether a single population mean differs from a hypothesized value μ₀, using the statistic t = (x̄ − μ₀) / (s / √n) with df = n − 1. The independent two-sample t-test compares means from two separate groups; the pooled version assumes equal population variances and uses df = n₁ + n₂ − 2, while Welch's t-test relaxes this assumption by approximating df via the Satterthwaite formula. Both tests rely on the t-distribution, which is heavier-tailed than the normal and accounts for the uncertainty in estimating σ from s.

Key assumptions include approximate normality of the data (or sufficient sample size for the CLT) and independence of observations. Always report a confidence interval alongside the p-value, and consider an effect size measure such as Cohen's d. When comparing more than two groups, transition to ANOVA rather than performing multiple t-tests, which inflates the Type I error rate. The two-sample t-test is equivalent to a simple linear regression with a binary predictor, a connection that generalizes naturally to multivariable models in advanced biostatistics.

Varsity Tutors • Biostatistics • One & Two-Sample t-Tests