The Short Answer: One Question Separates Them
A one-sample t-test compares one group's mean to a fixed number (a known or hypothesized population value). A two-sample t-test compares the means of two independent groups to each other. The single deciding question: are you comparing your data to a benchmark value, or to another group of data?
Both tests belong to the same family of statistical procedures developed by William Sealy Gosset — who published as "Student" in 1908 — to test whether a sample mean differs from what you'd expect by chance alone. The difference between them is not mathematical complexity; it's what you're comparing. A one-sample test asks "does my group match this standard?" A two-sample test asks "do these two groups match each other?"
What Is a One-Sample T-Test?
The test was created to handle a practical problem: you have data from one group, and you want to know whether that group's true average equals some target, standard, or historical benchmark. The benchmark (μ₀) must come from outside your data — it could be a regulatory standard, a prior study result, a manufacturer's claimed specification, or a national average. You do not estimate it from the same sample.
Because you are estimating the population standard deviation (σ) from the sample standard deviation (s), the test statistic follows a t-distribution rather than the standard normal distribution. The shape of that distribution depends on degrees of freedom: df = n − 1. With larger samples, the t-distribution approaches the normal distribution, which is why the t-test and z-test give nearly identical results when n is large. See the full guide to the one-sample t-test for a deeper treatment.
When to Use the One-Sample T-Test
Use the one-sample t-test when all three conditions hold: you have a single group, the outcome is measured on a continuous scale, and you have a specific target value to compare against. Real-world situations that fit this pattern include:
- A teacher wants to know whether her class's average score (x̄ = 73) matches the district benchmark of 70.
- A manufacturer checks whether the mean fill volume of bottles (x̄ = 497 ml) matches the specification of 500 ml.
- A nutritionist tests whether the mean daily calorie intake of study participants equals the national recommendation of 2,000 kcal.
- A hospital checks whether its mean patient wait time matches the national average of 24 minutes.
One-Sample T-Test Formula
x̄ = sample mean
μ₀ = hypothesized population mean
s = sample standard deviation
n = sample size
df = n − 1
SE = s / √n
The numerator (x̄ − μ₀) measures the raw difference between your sample mean and the target. The denominator (s / √n) is the standard error — how much the sample mean would vary from sample to sample due to chance alone. Dividing by the standard error converts the raw difference into a t-score: how many standard errors away from μ₀ your sample mean sits.
Assumptions of the One-Sample T-Test
| Assumption | What It Means | How to Check |
|---|---|---|
| Random sampling | The sample must be drawn randomly from the population | Review study design |
| Continuous data | The outcome is measured on an interval or ratio scale | Check variable type |
| Approximate normality | The population is normally distributed, or n ≥ 30 (CLT applies) | Histogram, Shapiro-Wilk test, or Q-Q plot |
| No extreme outliers | Outliers can distort the mean and inflate s | Boxplot, IQR rule, Grubbs' test |
| σ unknown | The population SD is estimated from sample data — otherwise use a z-test | Check whether σ is truly known |
What Is a Two-Sample T-Test?
The two-sample t-test answers a different question than the one-sample version: not "does my group match a benchmark?" but "do these two groups differ from each other?" The key word is independent — the participants in Group 1 must have no relationship to the participants in Group 2. If the same people appear in both conditions (before/after, left eye/right eye), the correct test is the paired samples t-test, not the two-sample t-test.
There are two common versions of the two-sample t-test. Student's version assumes the two populations have equal variances and uses a pooled standard error. Welch's version drops that assumption and is recommended as the default in most modern statistical software — including R's default behavior — because it is robust when variances are unequal without losing much power when they are equal.
When to Use the Two-Sample T-Test
The two-sample t-test fits when you have two independent groups and want to know whether their means differ. Common applications include:
- Comparing exam scores between students taught with Method A and students taught with Method B (two separate classrooms).
- Testing whether a drug group and a placebo group have different average blood pressure readings.
- A/B testing: comparing average session time for users who saw Design A versus Design B.
- Comparing average salaries between male and female employees in the same role.
- Checking whether defect rates differ between two production lines.
Two-Sample T-Test Formulas
s_p² = pooled variance = [(n₁−1)s₁² + (n₂−1)s₂²] / (n₁+n₂−2)
df = n₁ + n₂ − 2
df = Welch-Satterthwaite approximation
SE = √(s₁²/n₁ + s₂²/n₂)
The Welch-Satterthwaite formula for degrees of freedom is:
df = (s₁²/n₁ + s₂²/n₂)² / [(s₁²/n₁)²/(n₁−1) + (s₂²/n₂)²/(n₂−1)]
This gives a non-integer df in most cases, which is handled automatically by statistical software. See the detailed breakdown of equal vs unequal variance t-tests for guidance on when each version applies.
Assumptions of the Two-Sample T-Test
| Assumption | What It Means | How to Check |
|---|---|---|
| Independence between groups | The two groups contain different, unrelated subjects | Review study design |
| Independence within groups | Observations within each group are independent of each other | Review data collection process |
| Continuous data | The outcome is measured on an interval or ratio scale | Check variable type |
| Approximate normality | Each group's population is approximately normal, or n₁ and n₂ ≥ 30 | Histograms, Shapiro-Wilk on each group |
| Equal variances (Student's only) | σ₁² ≈ σ₂² — otherwise use Welch's t-test | Levene's test or F-test for equality of variances |
| No extreme outliers | Severe outliers distort both means and standard deviations | Boxplots for each group |
Most textbooks teach Student's t-test (equal variances assumed). In practice, Welch's t-test is safer and is now the default in R (t.test()), SPSS ("Separate Variance Estimates"), and many Python libraries. If you're unsure whether variances are equal, use Welch's — it performs well even when variances are equal, but Student's performs poorly when they are unequal.
Key Differences: One-Sample vs Two-Sample T-Test
| Feature | One-Sample T-Test | Two-Sample T-Test |
|---|---|---|
| Number of groups | 1 group | 2 independent groups |
| What it compares | Sample mean vs. a fixed value (μ₀) | Two sample means vs. each other |
| Null hypothesis | H₀: μ = μ₀ | H₀: μ₁ = μ₂ |
| Reference value | Known or hypothesized value (must exist independently) | Not needed — groups compared directly |
| Test statistic | t = (x̄ − μ₀) / (s / √n) | t = (x̄₁ − x̄₂) / SE_pooled |
| Degrees of freedom | df = n − 1 | df = n₁ + n₂ − 2 (Student's) or Welch's approximation |
| Standard error formula | SE = s / √n | SE = s_p × √(1/n₁ + 1/n₂) or √(s₁²/n₁ + s₂²/n₂) |
| Extra assumption | None beyond basic t-test requirements | Independence between groups; equal variances (Student's only) |
| Common use case | Quality control, benchmark testing, clinical targets | A/B testing, treatment vs control, group comparisons |
| Software defaults | R: t.test(x, mu=μ₀) | R: t.test(x, y) (Welch's by default) |
Extended Comparison: How Related Tests Compare
| Feature | Two-Sample T-Test | Paired T-Test |
|---|---|---|
| Subject structure | Different people in each group | Same people measured twice (or matched pairs) |
| How it works | Compares two group means directly | Computes difference per pair, then one-sample t on differences |
| Null hypothesis | H₀: μ₁ = μ₂ | H₀: μ_d = 0 |
| Degrees of freedom | n₁ + n₂ − 2 | n_pairs − 1 |
| Statistical power | Lower — between-subject variability is noise | Higher — removes between-subject variability |
| Typical use | RCTs with separate treatment/control groups | Pre/post studies, crossover trials, matched pairs |
| Feature | Two-Sample T-Test | Welch's T-Test |
|---|---|---|
| Variance assumption | Equal population variances (σ₁² = σ₂²) | No assumption about variances |
| Degrees of freedom | n₁ + n₂ − 2 (integer) | Welch-Satterthwaite formula (non-integer) |
| Pooled SD | Yes | No |
| When to use | When Levene's test confirms equal variances | Default recommendation; robust to variance differences |
| Feature | One-Sample T-Test | One-Sample Z-Test |
|---|---|---|
| Population SD | Unknown — estimated from sample (s) | Known — σ is given |
| Distribution used | t-distribution (heavier tails) | Standard normal distribution |
| When to use | Typical research — σ is almost never known | Only when σ is truly known from theory or large prior studies |
| Critical value at α = 0.05 (two-tailed) | Depends on df (e.g., t* = 2.048 for df = 29) | Always z* = 1.96 |
Decision Guide: Which T-Test Should You Use?
T-Test Decision Tree
e.g., Does our mean = 500 ml?
When in doubt between Student's two-sample t-test and Welch's t-test, choose Welch's. Modern statistical software defaults to Welch's because it is more robust to violations of the equal-variance assumption without a meaningful penalty when variances happen to be equal. The equal vs unequal variance guide covers the formal test for deciding.
The CHOOSE Framework for T-Test Selection
CHOOSE: A 6-Step Decision Framework for T-Test Selection
Worked Examples: Step-by-Step Calculations
Example 1 — One-Sample T-Test: Student Exam Scores
Problem: A statistics instructor believes the national average score on a standardized exam is 70. She randomly selects 25 students from her class and records their scores. The sample produces x̄ = 75.4 with s = 12.8. At α = 0.05, is there evidence that her students' mean score differs from 70?
State hypotheses: H₀: μ = 70 | H₁: μ ≠ 70 (two-tailed — testing for any difference)
Significance level and critical value: α = 0.05, two-tailed. df = n − 1 = 25 − 1 = 24. From the t-distribution table, t* = ±2.064.
Check assumptions: Random sample ✓. Scores are continuous ✓. n = 25; normality assumed for exam scores ✓. No information on extreme outliers — check boxplot in practice.
Calculate the test statistic:
SE = s / √n = 12.8 / √25 = 12.8 / 5 = 2.56
t = (75.4 − 70) / 2.56 = 5.4 / 2.56 = 2.109
Find p-value: |t| = 2.109 with df = 24. Using t-distribution software or table: p ≈ 0.046
Decision: p = 0.046 < α = 0.05. Also, |t| = 2.109 > t* = 2.064. Reject H₀.
✅ Conclusion: At the 5% significance level, there is sufficient evidence that the mean score of the instructor's students (x̄ = 75.4) differs from the national benchmark of 70. The class performed above the benchmark. Cohen's d = (75.4 − 70) / 12.8 = 0.42 — a moderate effect size.
Example 2 — Two-Sample T-Test: Drug vs Placebo Blood Pressure
Problem: A clinical trial tests a new antihypertensive drug. 30 patients receive the drug (Group 1) and 30 receive a placebo (Group 2). After 8 weeks, mean systolic blood pressure reductions are: Drug: x̄₁ = 14.2 mmHg, s₁ = 6.1; Placebo: x̄₂ = 8.7 mmHg, s₂ = 9.4. At α = 0.05, does the drug reduce blood pressure more than placebo?
State hypotheses: H₀: μ₁ = μ₂ (drug and placebo produce the same reduction) | H₁: μ₁ > μ₂ (drug reduces BP more — one-tailed)
Check variance equality: s₁ = 6.1, s₂ = 9.4 — ratio s₂/s₁ ≈ 1.54. Variances differ enough to recommend Welch's t-test. α = 0.05, one-tailed.
Check assumptions: Two independent groups ✓. Continuous outcome ✓. n₁ = n₂ = 30 → CLT applies ✓. Subjects in drug group are different from subjects in placebo group ✓.
Calculate test statistic:
SE = √(6.1²/30 + 9.4²/30) = √(37.21/30 + 88.36/30) = √(1.2403 + 2.9453) = √4.1856 = 2.046
t = (14.2 − 8.7) / 2.046 = 5.5 / 2.046 = 2.688
Degrees of freedom (Welch-Satterthwaite): df ≈ 48.7 (use software for exact value). One-tailed p-value for t = 2.688 with df ≈ 48: p ≈ 0.005
Decision: p = 0.005 < α = 0.05. Reject H₀. The drug group showed significantly greater BP reduction.
✅ Conclusion: At the 5% significance level, there is sufficient evidence that the drug reduces systolic blood pressure more than the placebo (mean difference = 5.5 mmHg). Cohen's d = 5.5 / s_pooled — the effect is clinically relevant. Note: this is why Welch's test was used; Student's test would have been incorrect given the unequal standard deviations (6.1 vs 9.4).
How to Run These Tests in Software
R
# One-sample t-test: compare sample mean to μ₀ = 70 scores <- c(78, 82, 65, 71, 80, 75, 88, 69, 74, 77) t.test(scores, mu = 70, alternative = "two.sided", conf.level = 0.95) # Output: t statistic, df, p-value, confidence interval, sample mean
# Welch's two-sample t-test (var.equal = FALSE is the default) drug <- c(15, 12, 18, 14, 13, 16) placebo <- c(8, 10, 9, 7, 11, 6) t.test(drug, placebo, alternative = "greater", var.equal = FALSE) # For Student's (equal variances), set var.equal = TRUE
Python (SciPy)
from scipy import stats import numpy as np scores = np.array([78, 82, 65, 71, 80, 75, 88, 69, 74, 77]) # One-sample t-test against μ₀ = 70 t_stat, p_value = stats.ttest_1samp(scores, popmean=70) print(f"t = {t_stat:.4f}, p = {p_value:.4f}")
from scipy import stats drug = [15, 12, 18, 14, 13, 16] placebo = [8, 10, 9, 7, 11, 6] # Welch's t-test (equal_var=False is the default) t_stat, p_value = stats.ttest_ind(drug, placebo, equal_var=False, alternative='greater') print(f"t = {t_stat:.4f}, p = {p_value:.4f}") # Student's (equal variances): equal_var=True
Excel
Excel has built-in functions for both tests. Navigate to Data → Data Analysis → t-Test or use these formulas directly:
=== One-Sample T-Test === # Calculate t-statistic manually: = (AVERAGE(A2:A26) - 70) / (STDEV(A2:A26) / SQRT(COUNT(A2:A26))) # Two-tailed p-value: = T.TEST(A2:A26, reference_array_equal_to_mu0, 2, 1) === Two-Sample T-Test === # Data Analysis → t-Test: Two-Sample Assuming Unequal Variances (Welch's) = T.TEST(A2:A31, B2:B31, 1, 3) # Tails: 1=one-tailed, 2=two-tailed # Type: 1=paired, 2=equal variance, 3=unequal variance (Welch's)
For a guided walk-through, see the interactive t-test calculator on Statistics Fundamentals, which handles both test types with step-by-step output.
Interactive T-Test Calculator
One-Sample & Two-Sample T-Test Calculator
Common Mistakes and How to Avoid Them
| Mistake | Wrong Approach | Correct Approach |
|---|---|---|
| Using a one-sample test to compare two groups | Running t.test(group1, mu=mean(group2)) — treating one group's mean as a fixed μ₀ | Use a two-sample t-test. The mean of group2 carries its own uncertainty and cannot be treated as a known value. |
| Using a two-sample test on paired data | Treating before/after measurements from the same subjects as two independent groups | Use the paired t-test. Ignoring the pairing wastes statistical power and violates the independence assumption. |
| Always using Student's instead of Welch's | Assuming equal variances without testing; using Student's two-sample formula when s₁ and s₂ differ substantially | Default to Welch's t-test. Run Levene's test if you want to formally check. Student's is fine when variances are confirmed equal. |
| Confusing statistical significance with practical importance | Reporting only p < 0.05 and concluding the difference is large or important | Always report effect size (Cohen's d) alongside p-value. A large n can produce a tiny p-value for a meaningless difference. |
| Choosing one-tailed test after seeing the data | Looking at which mean is larger, then choosing the matching directional alternative | The tails of the test must be specified before collecting data. Switching after seeing results halves your p-value dishonestly. |
| Running multiple t-tests instead of ANOVA | Comparing 3+ groups with repeated pairwise t-tests (e.g., A vs B, A vs C, B vs C) | Use one-way ANOVA for 3+ groups to control the family-wise error rate. |
Effect Size: Cohen's d for Both Tests
A statistically significant result tells you the observed difference is unlikely to be due to chance. It says nothing about whether the difference matters in practice. Effect size addresses that gap. For t-tests, Cohen's d is the standard measure.
d < 0.2 = negligible
d ≈ 0.2 = small
d ≈ 0.5 = medium
d ≥ 0.8 = large
Cohen's d thresholds were proposed by Jacob Cohen in Statistical Power Analysis for the Behavioral Sciences (1988). They are widely cited and used across disciplines, including the APA's guidelines on reporting statistical results. For full worked calculations and interpretation, see the Cohen's d guide and the effect size calculator on Statistics Fundamentals.
How to Report Results (APA Format)
Both tests share the same reporting template. Report the test type, t-statistic, degrees of freedom, p-value, confidence interval, and effect size. The APA Style Guide for statistics sets the standard most journals and academic programs follow.
APA Reporting Templates
One-Sample T-Test
A one-sample t-test indicated that the mean exam score (M = 75.40, SD = 12.80) was significantly higher than the benchmark of 70, t(24) = 2.11, p = .046, d = 0.42, 95% CI [0.11, 10.70].
Two-Sample T-Test (Welch's)
A Welch's independent-samples t-test revealed a significant difference in blood pressure reduction between the drug group (M = 14.20, SD = 6.10) and the placebo group (M = 8.70, SD = 9.40), t(48.7) = 2.69, p = .005, d = 0.70, 95% CI [1.38, 9.62].
Real-World Applications by Field
Healthcare
One-sample: checking whether a hospital's average treatment time meets the 4-hour target. Two-sample: comparing infection rates between a treatment group and a control group in a clinical trial.
Education
One-sample: testing whether a school's average SAT score matches the national average. Two-sample: comparing test scores between students taught with online vs in-person instruction.
Manufacturing
One-sample: verifying that the mean fill volume of a production run matches the labeled 500 ml. Two-sample: comparing defect rates between two production lines or two suppliers.
Data Science / A/B Testing
Two-sample: the standard test for A/B experiments — comparing mean conversion time, session length, or revenue between a control group and a variant group.
Business Analytics
One-sample: testing whether average customer satisfaction scores meet the company's 4.0 target. Two-sample: comparing average sales between two sales teams or two regions.
Agriculture / Biology
One-sample: comparing crop yield against the variety's published average. Two-sample: testing whether a new fertilizer produces higher yield than the control condition.
Entity and Formula Glossary
| Term | Symbol | Definition |
|---|---|---|
| One-Sample T-Test | — | Tests whether a single sample mean equals a known or hypothesized population value (μ₀) |
| Two-Sample T-Test | — | Tests whether the means of two independent samples are equal; also called independent samples t-test |
| Welch's T-Test | — | A variant of the two-sample t-test that does not assume equal population variances; recommended default |
| Paired T-Test | — | Tests whether the mean of pairwise differences equals zero; used when subjects appear in both conditions |
| Null Hypothesis | H₀ | The default claim being tested: μ = μ₀ (one-sample) or μ₁ = μ₂ (two-sample) |
| Alternative Hypothesis | H₁ | The research claim: can be two-tailed (≠), right-tailed (>), or left-tailed (<) |
| t-Statistic | t | The test statistic: standardized distance of the sample mean from the null hypothesis value, measured in standard errors |
| p-value | p | Probability of observing a t-statistic as extreme as the one computed, assuming H₀ is true; reject H₀ when p < α |
| Degrees of Freedom | df | A parameter of the t-distribution; df = n−1 for one-sample; df = n₁+n₂−2 for Student's; Welch's approximation for Welch's |
| Standard Error | SE | The estimated standard deviation of the sampling distribution of the mean; SE = s/√n for one-sample |
| Pooled Standard Deviation | s_p | Weighted average of the two group standard deviations; used only in Student's two-sample t-test |
| Effect Size (Cohen's d) | d | Standardized measure of the practical size of the difference; d = (x̄−μ₀)/s (one-sample) or (x̄₁−x̄₂)/s_p (two-sample) |
| Significance Level | α | Pre-set threshold for rejecting H₀; conventionally 0.05, meaning a 5% false-positive rate |
| Confidence Interval | CI | Range of plausible values for the population mean difference; a 95% CI does not contain μ₀ when p < 0.05 (two-tailed) |
| Statistical Power | 1−β | Probability of correctly rejecting a false H₀; increases with larger n and larger effect sizes |
| Population Mean | μ | The true (unknown) average of the entire population being studied |
| Sample Mean | x̄ | The average of the observed sample data; an unbiased estimator of μ |
| Equal Variance Assumption | σ₁²=σ₂² | The assumption that both populations have the same variance; required for Student's two-sample t-test; not required for Welch's |
| William Sealy Gosset | "Student" | The statistician who derived the t-distribution in 1908 while working at Guinness Brewery; published under the pseudonym "Student" |
Frequently Asked Questions
H₀: μ₁ − μ₂ = 0). The alternative hypothesis may be two-sided (μ₁ ≠ μ₂) or one-sided (μ₁ > μ₂ or μ₁ < μ₂), depending on the research question.