T-Tests Hypothesis Testing Worked Examples 32 min read July 27, 2026
BY: Statistics Fundamentals Team
Reviewed By: Minsa A (Senior Statistics Editor)

T-Test Examples: Step-by-Step Worked Problems & Real-Life Applications

A hospital wants to know whether a new drug lowers blood pressure. An educator tests whether one teaching method outperforms another. A factory checks whether a production batch meets weight specifications. Each scenario calls for a different type of t-test, but the underlying logic is the same: take the difference between what you observed and what you expected, divide by the standard error, and see whether the result is large enough to rule out chance.

This guide works through 10 fully solved t-test problems — three for the one-sample t-test, three for the independent samples t-test, two for the paired t-test, and two for Welch's t-test — each with a real-world scenario, all arithmetic shown, and a plain-English conclusion. The interactive calculator at the bottom runs any of the three test types directly in your browser.

What You'll Learn
  • ✓ What a t-test is and when to use each of the three types
  • ✓ The formula and 5-step procedure for every t-test variant
  • ✓ 10 fully worked examples with all arithmetic shown
  • ✓ Real-life applications in healthcare, education, manufacturing, and business
  • ✓ How to calculate and interpret effect size (Cohen's d)
  • ✓ Software code in R, Python, and Excel
  • ✓ The TEST Framework — a structured approach for any t-test problem
  • ✓ Common mistakes and how to avoid them

What Is a T-Test?

Definition — Student's T-Test
A t-test is a parametric hypothesis test used to compare one or two group means when the population standard deviation (σ) is unknown. It uses the t-distribution to determine whether the observed difference between means is large enough to be unlikely under the null hypothesis.
t = (observed difference) / (standard error)

William Sealy Gosset developed the t-test in 1908 while working at the Guinness brewery in Dublin, publishing under the pseudonym "Student" — hence the name Student's t-test. He needed a method for comparing small samples of barley yields when σ was unknown. The test Ronald Fisher later formalized is now one of the most widely used procedures in statistics, appearing in clinical trials, psychology studies, quality control, and A/B testing.

The intuition behind any t-test is simple. You expect two things to be equal (or a mean to equal some value). You collect data. The question is whether the gap you observe is genuine or whether sampling variability could plausibly explain it. The t-statistic measures that gap in units of standard error. Large |t| means the gap is large relative to the noise — and a low p-value follows.

The t-distribution has heavier tails than the normal distribution, which accounts for the extra uncertainty that comes from estimating σ from the sample. As sample size grows, the t-distribution approaches the normal distribution — with df > 120, the difference is negligible. Full background on this is in the t-distribution guide at Statistics Fundamentals.

3
Types of T-Tests
df=n−1
One-Sample Degrees of Freedom
0.05
Conventional α Level
±2.045
Critical Value, df=29, Two-Tailed

Types of T-Tests

Three variants cover nearly every mean-comparison problem in practice. Choosing the wrong type is one of the most common errors students make. The decision depends on two questions: how many groups are you comparing, and are those groups independent?

Feature One-Sample T-Test Independent T-Test Paired T-Test
Groups compared1 (vs. a constant)2 separate groups2 measurements, same subjects
IndependenceObservations independentGroups independentPairs are dependent
Degrees of freedomn − 1n₁ + n₂ − 2n − 1 (where n = number of pairs)
What it testsIs μ different from μ₀?Is μ₁ different from μ₂?Is the mean difference ≠ 0?
Typical useQuality control, benchmarkingA/B testing, clinical trialsBefore/after, matched pairs

One-Sample T-Test

Use this when you have a single group and want to know whether its mean matches a specific value. The "specific value" is a known standard, a regulatory threshold, a historical benchmark, or a manufacturer's claim. You do not need a second group — just a hypothesized value to compare against. For full theory, see the one-sample t-test guide.

Independent Samples T-Test

Use this when you have two separate groups and the subjects in one group have no relationship to the subjects in the other. The two groups must be truly independent — no person or subject appears in both. If the two groups have noticeably different variances (check with Levene's test), switch to Welch's t-test instead. The full procedure is at the two-sample t-test guide.

Paired Samples T-Test

Use this when each observation in one group corresponds to exactly one observation in the other — for example, the same person measured before and after a treatment, or two patients matched on age and health status. The key insight is that you reduce the problem to a one-sample test on the differences. See the complete walkthrough at the paired samples t-test guide.

T-Test Formulas

One-Sample T-Test Formula

One-Sample T-Test
t = (x̄ − μ₀) / (s / √n)
= sample mean μ₀ = hypothesized population mean s = sample standard deviation n = sample size df = n − 1

Independent Samples T-Test Formula (Equal Variances)

Independent (Pooled) T-Test
t = (x̄₁ − x̄₂) / (sₚ × √(1/n₁ + 1/n₂))
sₚ² = pooled variance = [(n₁−1)s₁² + (n₂−1)s₂²] / (n₁+n₂−2) df = n₁ + n₂ − 2

Paired T-Test Formula

Paired T-Test
t = d̄ / (s_d / √n)
= mean of differences (before − after, or Group A − Group B) s_d = standard deviation of differences n = number of pairs  |  df = n − 1

Welch's T-Test Formula (Unequal Variances)

Welch's T-Test (Unequal Variances)
t = (x̄₁ − x̄₂) / √(s₁²/n₁ + s₂²/n₂)
df = Welch-Satterthwaite approximation (see below) df ≈ (s₁²/n₁ + s₂²/n₂)² / [(s₁²/n₁)²/(n₁−1) + (s₂²/n₂)²/(n₂−1)]

Assumptions of a T-Test

Every t-test requires a set of conditions to be met before the results are trustworthy. Violating these assumptions does not always make the test useless — the t-test is robust to mild departures from normality when samples are large — but understanding each assumption helps you decide whether a t-test is appropriate or whether a nonparametric alternative (like the Mann-Whitney U test or Wilcoxon signed-rank test) would be more appropriate.

📏

Continuous Data

The dependent variable must be measured on an interval or ratio scale. T-tests are not appropriate for categorical (nominal or ordinal) data.

🔔

Approximate Normality

The data in each group should be approximately normally distributed. For n ≥ 30, the Central Limit Theorem means the t-test remains valid even without perfect normality. For smaller samples, check with a Q-Q plot or a Shapiro-Wilk test.

🎲

Random Sampling

Subjects should be randomly selected from the population. Non-random samples introduce bias that cannot be corrected after the fact.

⚖️

Equal Variances (Independent T-Test Only)

The standard independent t-test (pooled) assumes the two population variances are equal (homogeneity of variance). Test this with Levene's test. If variances differ significantly, use Welch's t-test, which does not make this assumption. Guidance on checking this is at the equal vs. unequal variance guide.

🔗

Independence of Observations

For the one-sample and independent tests, each observation must be independent of the others. For the paired test, pairs are dependent by design — but observations within a pair must still be independent of observations in other pairs.

The TEST Framework — A Structured Approach

The following four-step framework organizes every t-test problem in a consistent, reproducible way. It is designed to prevent the most common errors: choosing the wrong test type, skipping assumption checks, and misinterpreting the conclusion.

The TEST Framework for T-Tests (Original)

T
Type — Identify the correct t-test Is there one group or two? Are the two groups independent or paired? Are variances equal? This step determines whether you run a one-sample, independent, paired, or Welch's t-test.
E
Examine — Check assumptions before calculating Is the data continuous? Is normality reasonable? Are observations independent? Have you tested for equal variances if using the pooled independent t-test? Skipping this step can invalidate the entire analysis.
S
Solve — Calculate the t-statistic and p-value Apply the formula for your chosen test type. Compute degrees of freedom. Look up the critical value in the t-distribution table or compute the p-value with software. Calculate Cohen's d to report effect size.
T
Test — Make a decision and state a plain-English conclusion If p < α, reject H₀ and state what was found in context. If p ≥ α, fail to reject H₀ — you do not "accept" H₀. Always report the t-statistic, degrees of freedom, p-value, and effect size in your conclusion.

One-Sample T-Test Examples

A one-sample t-test compares a sample mean to a specific number you already know — a regulatory standard, a manufacturer's claim, a historical benchmark, or any fixed reference point. The null hypothesis is always H₀: μ = μ₀. The test statistic is t = (x̄ − μ₀) / (s/√n) with df = n − 1.

Example 1 — Light Bulb Lifespan (Manufacturing)

Worked Example 1 — One-Sample T-Test

Problem: A manufacturer claims its LED light bulbs last an average of 1,000 hours. A quality control inspector randomly selects 15 bulbs and records the following lifespans (hours): 978, 1010, 965, 982, 1024, 990, 1003, 971, 1018, 985, 962, 995, 1007, 973, 1012. The sample mean is x̄ = 991.7 hours and s = 19.8 hours. At α = 0.05 (two-tailed), does the data contradict the manufacturer's claim?

One-Sample T-Test
t = (x̄ − μ₀) / (s / √n)
1

State hypotheses: H₀: μ = 1,000 hours  |  H₁: μ ≠ 1,000 hours (two-tailed — testing whether the true mean differs from the claim in either direction)

2

Significance level and critical value: α = 0.05. Degrees of freedom: df = 15 − 1 = 14. From the t-distribution table, the two-tailed critical value is t* = ±2.145.

3

Check assumptions: Data are continuous (hours). Sample is random. With n = 15, normality matters — a Q-Q plot shows no severe skewness. The assumption of approximate normality is reasonable.

4

Calculate the test statistic:
SE = s/√n = 19.8/√15 = 19.8/3.873 = 5.113
t = (991.7 − 1000) / 5.113 = −8.3 / 5.113 = −1.624

5

Decision: |t| = 1.624 < t* = 2.145. The t-statistic does not fall in the rejection region. p ≈ 0.127 > 0.05. Fail to reject H₀.
Effect size: Cohen's d = (x̄ − μ₀) / s = (991.7 − 1000) / 19.8 = −0.419 (medium effect, but not statistically significant at n = 15)

✅ Conclusion: At the 5% significance level, there is not sufficient evidence to conclude that the bulbs' average lifespan differs from the claimed 1,000 hours (t(14) = −1.624, p ≈ 0.127). The manufacturer's claim is consistent with the data.

Critical values from the t-distribution table. Effect size interpretation follows Cohen, J. (1988). Statistical Power Analysis for the Behavioral Sciences (2nd ed.).

Example 2 — Student Exam Scores (Education)

Worked Example 2 — One-Sample T-Test

Problem: A professor believes students in her advanced statistics class perform above the national average exam score of 72 points. She collects scores from 20 students: x̄ = 76.4, s = 8.2. Test at α = 0.05 (one-tailed, upper).

1

Hypotheses: H₀: μ ≤ 72  |  H₁: μ > 72 (one-tailed, upper — the professor expects higher scores)

2

Critical value: df = 19, α = 0.05 (one-tailed upper). From the t-table: t* = 1.729.

3

Check assumptions: Continuous data (exam points). n = 20, moderate size — assume approximate normality from the exam score distribution. Random sample.

4

Calculate:
SE = 8.2 / √20 = 8.2 / 4.472 = 1.834
t = (76.4 − 72) / 1.834 = 4.4 / 1.834 = 2.399

5

Decision: t = 2.399 > t* = 1.729. Reject H₀. p ≈ 0.013 < 0.05.
Effect size: d = (76.4 − 72) / 8.2 = 0.537 (medium-to-large effect)

✅ Conclusion: At the 5% significance level, there is sufficient evidence that students in this class score above the national average (t(19) = 2.399, p ≈ 0.013, d = 0.54). The result is statistically significant with a medium effect size.

Example 3 — Daily Calorie Intake (Healthcare)

Worked Example 3 — One-Sample T-Test

Problem: A dietitian wants to determine whether adults in a particular community have a different average daily calorie intake than the recommended 2,000 kcal. A random sample of 25 adults yields x̄ = 2,150 kcal with s = 300 kcal. Test at α = 0.01.

1

Hypotheses: H₀: μ = 2,000  |  H₁: μ ≠ 2,000 (two-tailed)

2

Critical value: df = 24, α = 0.01 (two-tailed). t* = ±2.797

3

Check assumptions: Continuous data (kcal). n = 25. Calorie intake data are typically right-skewed, but with n = 25 and no extreme outliers, the t-test remains reasonable. Random sample.

4

Calculate:
SE = 300 / √25 = 300 / 5 = 60
t = (2,150 − 2,000) / 60 = 150 / 60 = 2.500

5

Decision: |t| = 2.500 < t* = 2.797. Fail to reject H₀ at α = 0.01. (Note: would reject at α = 0.05 where t* = ±2.064.)
Effect size: d = 150 / 300 = 0.500 (medium effect)

✅ Conclusion: At the 1% significance level, there is insufficient evidence that average daily intake differs from 2,000 kcal (t(24) = 2.500, p ≈ 0.020). The result would be significant at α = 0.05 but not at the more stringent α = 0.01 threshold used here.

Independent Samples T-Test Examples

The independent samples t-test (also called the two-sample t-test) compares means from two separate, unrelated groups. The null hypothesis is H₀: μ₁ = μ₂, meaning no difference between the population means. When the two groups have equal variances, you use the pooled formula with df = n₁ + n₂ − 2. The full procedure and assumptions are at the two-sample t-test guide.

Example 4 — Two Teaching Methods (Education)

Worked Example 4 — Independent Samples T-Test

Problem: A school tests two teaching methods. Method A (n₁ = 20) produces exam scores with x̄₁ = 78 and s₁ = 10. Method B (n₂ = 20) produces scores with x̄₂ = 84 and s₂ = 11. Assuming equal variances, is there a statistically significant difference? Use α = 0.05 (two-tailed).

Pooled Independent T-Test
t = (x̄₁ − x̄₂) / (sₚ × √(1/n₁ + 1/n₂))
1

Hypotheses: H₀: μ₁ = μ₂  |  H₁: μ₁ ≠ μ₂ (two-tailed)

2

Critical value: df = 20 + 20 − 2 = 38, α = 0.05 (two-tailed). t* ≈ ±2.024

3

Check assumptions: Two independent groups, continuous data. Equal variances assumed (s₁ = 10 vs. s₂ = 11 — close enough). Random sampling.

4

Calculate pooled standard deviation:
sₚ² = [(n₁−1)s₁² + (n₂−1)s₂²] / (n₁+n₂−2)
sₚ² = [(19×100) + (19×121)] / 38 = [1900 + 2299] / 38 = 4199 / 38 = 110.5
sₚ = √110.5 = 10.512
SE = sₚ × √(1/20 + 1/20) = 10.512 × √0.10 = 10.512 × 0.3162 = 3.323
t = (78 − 84) / 3.323 = −6 / 3.323 = −1.805

5

Decision: |t| = 1.805 < t* = 2.024. p ≈ 0.079 > 0.05. Fail to reject H₀.
Effect size: d = (78 − 84) / 10.512 = −0.571 (medium effect — practically meaningful but not significant at n = 20 per group)

✅ Conclusion: At the 5% significance level, the difference between teaching methods is not statistically significant (t(38) = −1.805, p ≈ 0.079). However, the medium effect size (d = 0.57) suggests a potentially meaningful difference — a larger sample would have more power to detect it.

Example 5 — Drug vs. Placebo (Clinical Research)

Worked Example 5 — Independent Samples T-Test

Problem: In a clinical trial, 30 patients receive a new cholesterol-lowering drug and 30 receive a placebo. After 12 weeks, the drug group shows a mean LDL reduction of x̄₁ = 22.4 mg/dL (s₁ = 8.1) and the placebo group shows x̄₂ = 12.3 mg/dL (s₂ = 7.8). Test at α = 0.01 (two-tailed).

1

Hypotheses: H₀: μ₁ = μ₂  |  H₁: μ₁ ≠ μ₂ (two-tailed)

2

Critical value: df = 30 + 30 − 2 = 58. At α = 0.01 (two-tailed): t* ≈ ±2.660

3

Check assumptions: Two independent, randomly assigned groups. Continuous outcome. Variances appear similar (8.1 vs. 7.8). Equal-variance assumption reasonable.

4

Calculate:
sₚ² = [(29×65.61) + (29×60.84)] / 58 = [1902.69 + 1764.36] / 58 = 3667.05 / 58 = 63.22
sₚ = √63.22 = 7.951
SE = 7.951 × √(1/30 + 1/30) = 7.951 × 0.2582 = 2.053
t = (22.4 − 12.3) / 2.053 = 10.1 / 2.053 = 4.920

5

Decision: |t| = 4.920 > t* = 2.660. Reject H₀. p < 0.001.
Effect size: d = 10.1 / 7.951 = 1.270 (large effect)

✅ Conclusion: At the 1% significance level, the drug produces a significantly greater LDL reduction than the placebo (t(58) = 4.920, p < 0.001, d = 1.27). The large effect size indicates this is both statistically and practically significant.

Example 6 — Website Conversion Rates (A/B Testing)

Worked Example 6 — Independent Samples T-Test

Problem: A marketing analyst runs an A/B test on two landing page designs. Version A (n₁ = 50) produces a mean conversion score of x̄₁ = 3.8 (on a 1–10 scale) with s₁ = 1.4. Version B (n₂ = 50) produces x̄₂ = 4.5 with s₂ = 1.6. Test at α = 0.05 (one-tailed, upper: is B better than A?).

1

Hypotheses: H₀: μ_B ≤ μ_A  |  H₁: μ_B > μ_A (one-tailed upper)

2

Critical value: df = 98, α = 0.05 (one-tailed). t* ≈ 1.661

3

Check assumptions: Two independent groups, continuous scale, random samples. Variances close (1.4 vs. 1.6), equal-variance assumption acceptable. n = 50 per group provides adequate power.

4

Calculate:
sₚ² = [(49×1.96) + (49×2.56)] / 98 = [96.04 + 125.44] / 98 = 221.48 / 98 = 2.260
sₚ = 1.503
SE = 1.503 × √(1/50 + 1/50) = 1.503 × 0.2000 = 0.301
t = (4.5 − 3.8) / 0.301 = 0.7 / 0.301 = 2.326

5

Decision: t = 2.326 > t* = 1.661. Reject H₀. p ≈ 0.011 < 0.05.
Effect size: d = 0.7 / 1.503 = 0.466 (medium effect)

✅ Conclusion: Version B produces significantly higher conversion scores than Version A at the 5% level (t(98) = 2.326, p ≈ 0.011, d = 0.47). The analyst should consider rolling out Version B.

Paired Samples T-Test Examples

The paired t-test works by reducing the two-column problem to a one-column problem. You compute the difference for each pair, then run a one-sample t-test on those differences against a hypothesized mean difference of zero. Because you remove between-subject variability, the paired test is more statistically powerful than the independent test when the pairing is justified. Full theory is at the paired samples t-test guide.

Example 7 — Blood Pressure Before and After Treatment

Worked Example 7 — Paired Samples T-Test

Problem: Ten patients have their systolic blood pressure measured before and after 8 weeks on a new medication. The differences (before − after) in mmHg are: 12, 8, 15, 6, 10, 14, 9, 11, 7, 13. Test whether the medication significantly reduces blood pressure at α = 0.05 (one-tailed upper: does the drug reduce pressure, i.e., is d̄ > 0?).

Paired T-Test
t = d̄ / (s_d / √n)
1

Hypotheses: H₀: μ_d ≤ 0  |  H₁: μ_d > 0 (one-tailed: drug reduces pressure so before − after > 0)

2

Critical value: df = n − 1 = 9. One-tailed α = 0.05. t* = 1.833

3

Check assumptions: Matched pairs (same patients). Differences are continuous and approximately normally distributed (reasonable for small, symmetric set). Random sample of patients.

4

Calculate d̄ and s_d:
Differences: 12, 8, 15, 6, 10, 14, 9, 11, 7, 13
d̄ = (12+8+15+6+10+14+9+11+7+13) / 10 = 105 / 10 = 10.5
s_d = √[Σ(dᵢ − d̄)² / (n−1)] = √[((1.5²+2.5²+4.5²+4.5²+0.5²+3.5²+1.5²+0.5²+3.5²+2.5²)) / 9]
   = √[(2.25+6.25+20.25+20.25+0.25+12.25+2.25+0.25+12.25+6.25) / 9]
   = √[82.5 / 9] = √9.167 = 3.028
SE = s_d / √n = 3.028 / √10 = 3.028 / 3.162 = 0.958
t = 10.5 / 0.958 = 10.96

5

Decision: t = 10.96 ≫ t* = 1.833. Reject H₀. p < 0.0001.
Effect size: d = d̄ / s_d = 10.5 / 3.028 = 3.468 (very large effect)

✅ Conclusion: The medication produces a statistically significant reduction in blood pressure (t(9) = 10.96, p < 0.0001, d = 3.47). On average, the drug reduced systolic blood pressure by 10.5 mmHg, an extremely large effect.

Example 8 — Employee Productivity Before and After Training

Worked Example 8 — Paired Samples T-Test

Problem: A company measures the productivity score (tasks completed per day) of 12 employees before and after a training program. Summary statistics on the differences (after − before): d̄ = 3.2, s_d = 4.1, n = 12. Did the training improve productivity? Test at α = 0.05 (one-tailed upper: H₁: μ_d > 0).

1

Hypotheses: H₀: μ_d ≤ 0  |  H₁: μ_d > 0

2

Critical value: df = 11, α = 0.05 (one-tailed). t* = 1.796

3

Assumptions: Same 12 employees measured twice (matched pairs). Productivity scores are continuous. n = 12 — check for approximate normality of differences; no extreme outliers reported.

4

Calculate:
SE = s_d / √n = 4.1 / √12 = 4.1 / 3.464 = 1.184
t = d̄ / SE = 3.2 / 1.184 = 2.703

5

Decision: t = 2.703 > t* = 1.796. Reject H₀. p ≈ 0.010.
Effect size: d = 3.2 / 4.1 = 0.780 (large effect)

✅ Conclusion: The training program significantly improved employee productivity (t(11) = 2.703, p ≈ 0.010, d = 0.78). Employees completed an average of 3.2 more tasks per day after training, a large effect.

Welch's T-Test Examples

Welch's t-test is the appropriate choice when the two groups have unequal population variances. It adjusts the degrees of freedom using the Welch-Satterthwaite equation, resulting in a non-integer df that is always smaller than or equal to the df from the pooled t-test. Many statisticians recommend using Welch's t-test by default for independent comparisons, since it gives the correct Type I error rate whether or not variances are equal. See the detailed comparison at equal vs. unequal variance.

Example 9 — Salary Comparison Between Departments

Worked Example 9 — Welch's T-Test

Problem: An HR analyst compares annual salaries between two departments. Engineering (n₁ = 15): x̄₁ = $92,000, s₁ = $18,000. Marketing (n₂ = 12): x̄₂ = $78,000, s₂ = $7,500. Levene's test indicates unequal variances (p = 0.004). Test at α = 0.05 (two-tailed) whether salaries differ.

Welch's T-Test
t = (x̄₁ − x̄₂) / √(s₁²/n₁ + s₂²/n₂)
1

Hypotheses: H₀: μ₁ = μ₂  |  H₁: μ₁ ≠ μ₂ (two-tailed)

2

Degrees of freedom (Welch-Satterthwaite):
v₁ = s₁²/n₁ = 324,000,000/15 = 21,600,000
v₂ = s₂²/n₂ = 56,250,000/12 = 4,687,500
df ≈ (21,600,000 + 4,687,500)² / [(21,600,000²/14) + (4,687,500²/11)]
   = (26,287,500)² / [33,342,857,142,857 + 1,999,893,394,495]
   ≈ 691,230,468,750,000 / 35,342,750,537,352 ≈ 19.56 ≈ 19 df
Critical value: df = 19, α = 0.05 (two-tailed). t* ≈ ±2.093

3

Assumptions: Two independent groups. Continuous outcome. Variances are unequal (Levene's test significant) → Welch's test is correct. Random samples.

4

Calculate:
SE = √(s₁²/n₁ + s₂²/n₂) = √(21,600,000 + 4,687,500) = √26,287,500 = 5,127.1
t = (92,000 − 78,000) / 5,127.1 = 14,000 / 5,127.1 = 2.731

5

Decision: t = 2.731 > t* = 2.093. Reject H₀. p ≈ 0.013.
Effect size: d = (92,000 − 78,000) / √[(18,000² + 7,500²)/2] = 14,000 / 13,893 ≈ 1.008 (large)

✅ Conclusion: Engineering salaries are significantly higher than Marketing salaries (t(19) = 2.731, p ≈ 0.013, d ≈ 1.01). Because variances were unequal, Welch's t-test was the appropriate choice over the standard pooled test.

Example 10 — Crop Yield Comparison (Agriculture)

Worked Example 10 — Welch's T-Test

Problem: A researcher compares wheat yield (kg/hectare) between two fertilizer treatments. Fertilizer A (n₁ = 10): x̄₁ = 4,850, s₁ = 120. Fertilizer B (n₂ = 8): x̄₂ = 4,620, s₂ = 320. Variances are clearly unequal. Test at α = 0.05 (two-tailed).

1

Hypotheses: H₀: μ₁ = μ₂  |  H₁: μ₁ ≠ μ₂

2

Welch df:
v₁ = 120²/10 = 14,400/10 = 1,440  |  v₂ = 320²/8 = 102,400/8 = 12,800
df ≈ (1,440 + 12,800)² / [(1,440²/9) + (12,800²/7)] = (14,240)² / [230,400 + 23,405,714]
   ≈ 202,777,600 / 23,636,114 ≈ 8.58 ≈ 8 df
t* at df=8, α=0.05 (two-tailed) = ±2.306

3

Assumptions: Two independent plots assigned to different treatments. Continuous yield data. Variances clearly unequal (ratio > 7:1). Welch's test required.

4

Calculate:
SE = √(v₁ + v₂) = √(1,440 + 12,800) = √14,240 = 119.33
t = (4,850 − 4,620) / 119.33 = 230 / 119.33 = 1.928

5

Decision: |t| = 1.928 < t* = 2.306. Fail to reject H₀. p ≈ 0.090.
Effect size: d = 230 / √[(120² + 320²)/2] = 230 / √56,800 = 230 / 238.5 ≈ 0.964 (large — but power is low with only n = 8 and 10)

✅ Conclusion: The difference in crop yield between the two fertilizers is not statistically significant at α = 0.05 (t(8) = 1.928, p ≈ 0.090). However, the large effect size (d ≈ 0.96) and the small sample suggest this study was underpowered. A larger trial is warranted.

Which T-Test Should You Use?

Use the statistical test selector for a comprehensive guide covering all tests. For t-tests specifically, this decision tree covers the most common scenarios:

T-Test Decision Guide

How many groups?
One group compared to a constant → One-Sample T-Test
Two groups — are they independent?
No — same subjects or matched pairs → Paired T-Test
Two independent groups — equal variances?
Yes → Independent (Pooled) T-Test    No → Welch's T-Test
Two independent groups — variance unknown, or want a safe default?
Use Welch's T-Test (works whether variances are equal or not)
More than two groups?
Use ANOVA instead of multiple t-tests (see ANOVA guide)
⚠️
Running multiple t-tests inflates error rates

If you compare three groups using three separate t-tests, the probability of at least one false positive at α = 0.05 rises to roughly 14%. Use a one-way ANOVA followed by post-hoc tests (Tukey HSD, Bonferroni) when you have more than two groups. See the T-Test vs. ANOVA guide for details.

T-Test vs. Z-Test vs. ANOVA

Feature T-Test Z-Test ANOVA
σ known?No (estimated from sample)Yes (or n > 30)No
Number of groups1 or 21 or 22 or more
Distribution usedt-distributionStandard normalF-distribution
Degrees of freedomn−1 or n₁+n₂−2n−1 (or ∞)Between k−1, Within n−k
Full guideT-Test vs Z-TestZ-Test GuideANOVA Guide

How to Calculate and Interpret Effect Size (Cohen's d)

Statistical significance tells you whether an effect exists. Effect size tells you how large that effect is. These are separate questions. A t-test with 10,000 participants will produce a significant result for a trivial difference; a test with 10 participants may fail to detect a large but real effect. Cohen's d is the most widely reported effect size for t-tests.

Cohen's d — Effect Size for T-Tests
d = (x̄₁ − x̄₂) / sₚ   or   d = (x̄ − μ₀) / s
Small d = 0.2 Medium d = 0.5 Large d = 0.8

The American Statistical Association recommends reporting effect sizes alongside p-values in all published research. A significant p-value with a tiny d (e.g., d = 0.05) means the effect, while real, is too small to matter in practice. Conversely, a non-significant p-value with a large d (e.g., d = 0.90) suggests the study was underpowered — there likely is a real effect, but the sample was too small to detect it reliably.

Real-Life Applications of T-Tests

🏥

Clinical Trials

Comparing a new drug to a placebo using an independent t-test. If the same patients receive both treatments in sequence, a paired t-test is used instead.

🎓

Education Research

Testing whether a new curriculum raises test scores above the national average (one-sample) or comparing two teaching methods (independent).

🏭

Quality Control

Checking whether a production batch meets a weight or dimension specification using a one-sample t-test against the design target.

💼

A/B Testing

Comparing conversion rates, click-through rates, or engagement metrics between two versions of a product, page, or email campaign.

🌾

Agriculture

Comparing crop yields between two fertilizers or irrigation methods using an independent or Welch's t-test depending on variance equality.

🧠

Psychology

Measuring cognitive performance before and after an intervention using a paired t-test, removing between-subject variability.

Running a T-Test in R, Python, and Excel

Every major statistics package handles all three t-test variants with a single function call. The examples below replicate Example 5 (drug vs. placebo, independent t-test). For full software tutorials, see the statistical interpretation guide.

# One-Sample T-Test
x <- c(978,1010,965,982,1024,990,1003,971,1018,985,962,995,1007,973,1012)
t.test(x, mu = 1000, alternative = "two.sided")

# Independent T-Test (Welch's by default)
drug   <- c(18,24,20,25,23,22,19,26,21,24, # 30 values...
placebo <- c(10,14,12,11,13,15, # 30 values...
t.test(drug, placebo, var.equal = FALSE)   # Welch's
t.test(drug, placebo, var.equal = TRUE)    # Pooled

# Paired T-Test
before <- c(145,138,152,149,143,156,148,140,151,147)
after  <- c(133,130,137,143,133,142,139,129,144,134)
t.test(before, after, paired = TRUE, alternative = "greater")

# Effect size (Cohen's d) — install effsize package
library(effsize)
cohen.d(drug, placebo)
from scipy import stats
import numpy as np

# One-Sample T-Test
x = [978,1010,965,982,1024,990,1003,971,1018,985,962,995,1007,973,1012]
t_stat, p_val = stats.ttest_1samp(x, popmean=1000)
print(f"t = {t_stat:.4f}, p = {p_val:.4f}")

# Independent T-Test (Welch's — equal_var=False)
drug    = [22.4, 18.1, 25.3]  # full data...
placebo = [12.3, 10.5, 14.2]  # full data...
t_stat, p_val = stats.ttest_ind(drug, placebo, equal_var=False)

# Paired T-Test
before = [145,138,152,149,143,156,148,140,151,147]
after  = [133,130,137,143,133,142,139,129,144,134]
t_stat, p_val = stats.ttest_rel(before, after)

# Cohen's d (manual)
def cohens_d(g1, g2):
    diff = np.mean(g1) - np.mean(g2)
    n1,n2 = len(g1), len(g2)
    s_pool = np.sqrt(((n1-1)*np.var(g1,ddof=1) + (n2-1)*np.var(g2,ddof=1)) / (n1+n2-2))
    return diff / s_pool
-- One-Sample T-Test in Excel --
Store data in A1:A15. In B1, enter the formula:
=T.TEST(A1:A15, {1000,1000,...}, 2, 1)  ← workaround: compare to constant

Better approach for one-sample:
=T.DIST.2T(ABS((AVERAGE(A1:A15) - 1000) / (STDEV(A1:A15) / SQRT(COUNT(A1:A15)))), COUNT(A1:A15)-1)

-- Independent T-Test (Data Analysis ToolPak) --
Data → Data Analysis → t-Test: Two-Sample Assuming Equal Variances
   OR t-Test: Two-Sample Assuming Unequal Variances (Welch's)

-- Paired T-Test --
Data → Data Analysis → t-Test: Paired Two Sample for Means
   OR formula: =T.TEST(A1:A10, B1:B10, 2, 1)
   (last argument: 1=paired, 2=independent equal var, 3=independent unequal var)

-- Critical Value --
=T.INV.2T(0.05, df)   ← two-tailed critical value
=T.INV(0.95, df)       ← one-tailed upper critical value

Common T-Test Mistakes

Mistake Wrong Approach Correct Approach
Using pooled t-test with unequal variances Running the standard independent t-test when Levene's test is significant Switch to Welch's t-test, which does not assume equal variances
Running multiple t-tests on 3+ groups Three pairwise t-tests for three groups, each at α = 0.05 Use one-way ANOVA followed by Tukey's HSD post-hoc test
"Accepting" the null hypothesis "We accept H₀ and conclude there is no effect" "We fail to reject H₀. The data do not provide sufficient evidence of a difference"
Ignoring effect size Reporting only p < 0.05 without measuring practical significance Report Cohen's d alongside the p-value and confidence interval
Using paired test for independent groups Treating two randomly assigned groups as if they were before/after measurements Use the independent or Welch's t-test when groups share no natural pairing
Confusing statistical and practical significance "The drug is effective because p = 0.03" (with n = 10,000, d = 0.05) Report both: significant at p = 0.03, but effect size is negligible (d = 0.05)
Setting α after seeing the data (p-hacking) Lowering α from 0.05 to 0.10 after seeing that p = 0.07 Pre-register the significance level before data collection — this is the standard required by most journals and the American Statistical Association

T-Test Formula Cheat Sheet

Test Type Formula Degrees of Freedom Assumptions
One-Sample t = (x̄ − μ₀) / (s/√n) n − 1 Random sample, approx. normal
Independent (Pooled) t = (x̄₁−x̄₂) / (sₚ√(1/n₁+1/n₂)) n₁ + n₂ − 2 Independent groups, equal variances
Paired t = d̄ / (s_d/√n) n − 1 (pairs) Matched pairs, approx. normal diffs
Welch's t = (x̄₁−x̄₂) / √(s₁²/n₁+s₂²/n₂) Welch-Satterthwaite Independent groups, unequal OK
Cohen's d (one-sample) d = (x̄ − μ₀) / s Small: 0.2, Medium: 0.5, Large: 0.8
Cohen's d (two-sample) d = (x̄₁−x̄₂) / sₚ Same thresholds as above
Standard Error (one-sample) SE = s / √n
Pooled Variance sₚ² = [(n₁−1)s₁²+(n₂−1)s₂²]/(n₁+n₂−2) Used in independent pooled test

Entity & Terminology Glossary

Term Definition
Student's T-TestThe family of parametric tests for comparing means when σ is unknown, named for the pseudonym used by William Sealy Gosset (1908)
T-StatisticThe calculated test statistic: ratio of observed mean difference to standard error. Large |t| → strong evidence against H₀
Degrees of Freedom (df)A parameter of the t-distribution controlling its shape. Higher df → t-distribution closer to normal. See the degrees of freedom guide
P-ValueProbability of observing a t-statistic as extreme as the one calculated, assuming H₀ is true. See p-values guide
Significance Level (α)Pre-set threshold (conventionally 0.05) below which p-value triggers rejection of H₀. See significance level guide
Standard Error (SE)Standard deviation of the sampling distribution of the mean: SE = s/√n. Quantifies sampling variability. See standard deviation vs. standard error
Effect Size (Cohen's d)Standardized measure of the magnitude of a difference, independent of sample size. See effect size guide
Null Hypothesis (H₀)The default claim being tested, usually "no difference" or "mean equals a specified value." See null and alternative hypothesis guide
Alternative Hypothesis (H₁)The claim you're trying to support — either directional (one-tailed) or non-directional (two-tailed)
Statistical PowerProbability of correctly rejecting a false H₀. Depends on sample size, effect size, and α. See power of test guide
Type I Error (α)Rejecting H₀ when it is actually true (false positive). Probability equals α. See Type I and Type II errors
Type II Error (β)Failing to reject H₀ when it is false (false negative). Power = 1 − β
Confidence IntervalA range of plausible values for the true mean difference. Directly related to the t-test: if the 95% CI excludes zero, the two-tailed test is significant at α = 0.05. See confidence intervals guide
Normal DistributionThe bell-shaped distribution the t-distribution converges to for large df. See normal distribution guide
Pooled Variance (sₚ²)Weighted average of two sample variances, used in the standard independent t-test
Homogeneity of VarianceAssumption that both populations have the same variance σ². Tested with Levene's test
Welch-SatterthwaiteApproximation formula for degrees of freedom in Welch's t-test when variances are unequal

Interactive T-Test Calculator

Enter your summary statistics below to run a one-sample or two-sample t-test. For a paired t-test, compute the differences first and enter them as a one-sample problem (μ₀ = 0). The full-featured calculator with CSV upload is at statisticsfundamentals.com/calculators/t-test.

T-Test Calculator

Frequently Asked Questions

The three main types of t-tests are the one-sample t-test, which compares a sample mean to a known value; the independent samples t-test, which compares the means of two unrelated groups; and the paired samples t-test, which compares two related measurements taken from the same individuals or matched pairs. Although each test has a different formula, they all compare an observed difference to its standard error using a t-statistic.
Use a t-test when the population standard deviation is unknown, which is the most common situation in real-world research. A z-test is appropriate when the population standard deviation is known or when a large sample allows the normal approximation to be used. For large sample sizes, the results of the t-test and z-test become very similar.
The p-value measures how likely it would be to observe a t-statistic as extreme as the one calculated if the null hypothesis were actually true. A small p-value indicates that the observed difference is unlikely to have occurred by random chance alone. However, the p-value does not measure the size or practical importance of the effect, which should be evaluated using an effect size such as Cohen's d.
A t-test assumes that the dependent variable is continuous, observations are randomly sampled, and the data are approximately normally distributed, especially for small samples. Independent samples t-tests also require independent groups, while the pooled version additionally assumes equal population variances. If the equal variance assumption is not met, Welch's t-test is generally recommended.
A t-test result is interpreted using the t-statistic, degrees of freedom, p-value, and effect size. If the p-value is below the chosen significance level (commonly 0.05), the result is considered statistically significant and provides evidence against the null hypothesis. A complete interpretation should also describe the direction and magnitude of the observed difference, not just whether it is statistically significant.
There is no universal minimum sample size for a t-test. The required number of observations depends on the expected effect size, desired statistical power, and significance level. Detecting small effects requires much larger samples than detecting large effects. Performing a power analysis before collecting data is the best way to determine the appropriate sample size for your study.
Welch's t-test is a variation of the independent samples t-test that does not assume equal population variances. It adjusts the degrees of freedom to provide more accurate results when group variances or sample sizes differ. Because it performs well whether variances are equal or unequal, many statisticians recommend Welch's t-test as the default choice for comparing two independent groups.

References & Further Reading

  • Gosset, W.S. ("Student") (1908) — "The Probable Error of a Mean." Biometrika, 6(1), 1–25. The original paper deriving the t-distribution and one-sample test.
  • Cohen, J. (1988)Statistical Power Analysis for the Behavioral Sciences (2nd ed.). Hillsdale, NJ: Lawrence Erlbaum Associates. Definitive reference for effect size interpretation.
  • NIST Engineering Statistics Handbook — Section 7.3: t-Tests. itl.nist.gov. Authoritative reference from the National Institute of Standards and Technology.
  • Welch, B.L. (1947) — "The Generalization of 'Student's' Problem when Several Different Population Variances are Involved." Biometrika, 34(1/2), 28–35. Original paper introducing Welch's t-test.
  • OpenStax StatisticsIntroductory Statistics, Chapter 10: Hypothesis Testing with Two Samples. openstax.org. Free, peer-reviewed textbook.
  • Penn State STAT 415 — Matched Pairs, Two-Sample T-Tests. online.stat.psu.edu. Comprehensive university course material.
  • American Statistical Association (2016) — Statement on p-values: context, process, and purpose. The American Statistician, 70(2), 129–133. tandfonline.com
  • SciPy Documentation — scipy.stats.ttest_1samp, ttest_ind, ttest_rel. docs.scipy.org. Python implementation reference.