t-Test Explained: Independent, Paired and One-Sample, With Examples
Reviewed by Prof. Dr. Alexander Holtermann · Updated 16 October 2026 · 6 min read
A t-test checks whether two means differ significantly: two independent groups, two paired measurements, or one mean against a fixed value.
Key takeaways
- Three variants: the independent-samples t-test (two separate groups), the paired-samples t-test (same people measured twice) and the one-sample t-test (one mean against a known value).
- Assumptions: a metric outcome, independent observations, and approximately normal values per group (or differences); from about 30 per group the test is robust.
- For independent groups, use Welch’s t-test by default. It does not assume equal variances and loses almost no power when variances are equal.
- APA style: t(df) = value, p = value, d = value, for example t(13.46) = 3.42, p = .004, d = 1.71.
- For three or more groups use ANOVA; for small, clearly non-normal samples use the Mann-Whitney U test or the Wilcoxon signed-rank test.
What does a t-test do?
The t-test (Student’s t-test, after the pen name of W. S. Gosset) checks whether a difference between means is larger than you would expect from random sampling alone. The null hypothesis states that the population means are equal.
The test statistic relates the observed difference to its standard error:
t = difference between means / standard error of the difference
A larger difference, less variability and a larger sample all make t larger and the p-value smaller. The t-value is compared with a t-distribution whose shape depends on the degrees of freedom (df), roughly the sample size minus the number of estimated means.
| Variant | Question | Example | df |
|---|---|---|---|
| Independent samples | Do two separate groups differ? | Students with vs. without a study plan | n₁ + n₂ − 2 (Student) or Welch estimate |
| Paired samples | Does a value change within the same people? | Exam anxiety before vs. after a training | n − 1 (pairs) |
| One sample | Does a mean differ from a fixed value? | Study hours vs. the 20 planned hours | n − 1 |
Assumptions of the t-test
Check these points before you run the test and mention briefly in your methods section how you checked them.
- Level of measurement: the dependent variable is metric (interval or ratio), or a scale score from several Likert items.
- Independence: each person contributes one value per group; in the paired test, the pairs are independent of each other.
- Normality: values in each group (in the paired test: the differences) are approximately normal. From about 30 per group the test is robust; check small samples with a Q-Q plot and Shapiro-Wilk.
- Equal variances: only required for Student’s classic t-test (check with Levene’s test). Welch’s t-test does not need it.
- No extreme outliers: single extreme values can distort means and standard deviations.
Worked example: independent-samples t-test
You compare exam points of eight students with a study plan and eight without one.
With plan: 14, 16, 15, 18, 17, 19, 16, 17 → M = 16.50, SD = 1.60 Without plan: 13, 14, 12, 15, 16, 13, 14, 15 → M = 14.00, SD = 1.31
Welch’s test estimates the standard error from both variances separately: SE = √(s₁² / n₁ + s₂² / n₂). The degrees of freedom come from the Welch-Satterthwaite formula and are usually not a whole number.
| Step | Calculation | Result |
|---|---|---|
| Mean difference | 16.50 − 14.00 | 2.50 |
| Standard error | √(2.571 / 8 + 1.714 / 8) | 0.73 |
| t-value | 2.50 / 0.73 | 3.42 |
| Degrees of freedom (Welch) | Welch-Satterthwaite | 13.46 |
| p-value (two-sided) | t-distribution | .004 |
| 95% CI of the difference | 2.50 ± 2.153 × 0.73 | [0.92, 4.08] |
| Cohen’s d | 2.50 / 1.46 (pooled SD) | 1.71 |
Worked example: paired-samples t-test
Six students fill in an exam-anxiety questionnaire before and after a relaxation training. Because the same people are measured twice, you analyze the difference for each person. This removes stable differences between people and often makes the paired test much more powerful than a group comparison.
Formula: t = D̄ / (s_D / √n) with df = n − 1.
| Student | Before | After | Difference |
|---|---|---|---|
| 1 | 22 | 18 | 4 |
| 2 | 25 | 21 | 4 |
| 3 | 19 | 17 | 2 |
| 4 | 30 | 24 | 6 |
| 5 | 27 | 25 | 2 |
| 6 | 24 | 19 | 5 |
| Mean | 24.50 | 20.67 | 3.83 |
Worked example: one-sample t-test
Here you compare a sample mean with a known or specified value μ₀, such as a norm, a manufacturer’s claim or the workload stated in the course handbook. Formula: t = (M − μ₀) / (s / √n) with df = n − 1; effect size d = (M − μ₀) / s.
Welch’s t-test or Student’s t-test?
Student’s classic t-test assumes equal variances in both groups. The traditional recipe was to run Levene’s test first and pick the t-test depending on its result. Many methodologists now recommend always using Welch’s t-test: with equal variances it gives practically the same result, and with unequal variances, especially combined with unequal group sizes, it protects you from wrong p-values. The two-step procedure with a preliminary test also distorts error rates.
In your methods section you can simply write: “Because of its robustness to unequal variances, Welch’s t-test was used.” Report the Welch degrees of freedom with two decimals. Many programs, including R’s default t.test(), already use Welch.
How to report a t-test in APA style
A complete report contains the means and standard deviations of both groups, the test statistic with degrees of freedom, the exact p-value, an effect size and ideally the confidence interval of the difference. In the final document, t, p, d, M and SD are italicized.
Running a t-test in SPSS, R, JASP or Excel
Every statistics program gives the same t, df and p for the same variant of the test. Watch the defaults: R uses Welch’s test unless you set var.equal = TRUE, while SPSS prints both rows. A full walkthrough with output is in our article on the t-test in SPSS.
| Program | How to run it |
|---|---|
| SPSS | Analyze → Compare Means → Independent-Samples / Paired-Samples / One-Sample T Test |
| R | t.test(score ~ group, data = df); paired: t.test(x, y, paired = TRUE) |
| JASP / jamovi | T-Tests → Independent Samples, Paired Samples or One Sample T-Test |
| Excel | Function T.TEST(range1, range2, tails, type) or Analysis ToolPak (gives no effect size) |
Frequently asked questions
When should I use a t-test?
When you compare exactly two means of a metric variable: two groups, two time points, or one mean against a fixed value. For three or more groups use ANOVA.
What is the difference between a paired and an independent t-test?
In the independent t-test the values come from different people. In the paired t-test both values come from the same people or from matched pairs, for example before and after an intervention.
What if my data are not normally distributed?
From about 30 people per group the t-test is robust. With small groups and clear violations, use the Mann-Whitney U test (independent) or the Wilcoxon signed-rank test (paired).
What are the degrees of freedom in a t-test?
For Student’s t-test n₁ + n₂ − 2; for the paired and the one-sample test n − 1. For Welch’s test they are estimated from the variances and are usually not a whole number.
Which t-test should I use for unequal group sizes?
Welch’s t-test. Unequal variances distort the classic t-test most when the groups also differ in size.
Sources and further reading
- Howell, D. C. (2013). Statistical Methods for Psychology (8th ed.). Wadsworth Cengage Learning.
- Gravetter, F. J., & Wallnau, L. B. (2017). Statistics for the Behavioral Sciences (10th ed.). Cengage.
- Cohen, J. (1988). Statistical Power Analysis for the Behavioral Sciences (2nd ed.). Lawrence Erlbaum.
Your university’s examination regulations and style guide always take precedence.
Related articles
- Mann-Whitney U testThe Mann-Whitney U test compares two independent groups using ranks. It is the non-parametric alternative to the independent-samples t-test.
- ANOVAAnalysis of variance (ANOVA) tests whether three or more group means differ. A significant F-test is followed by post-hoc tests such as Tukey HSD.
- Effect sizeAn effect size tells you how large a difference or relationship is, independent of sample size. Cohen’s d of 0.2, 0.5 and 0.8 is small, medium, large.
- Testing for normalityCheck normality with a histogram or Q-Q plot, skewness and kurtosis, and the Shapiro-Wilk test. With large samples, plots matter more than p-values.
- Choosing a statistical testYour research question, the level of measurement of your outcome, the number of groups and whether samples are paired decide which statistical test fits.
- Reporting statistics in APAAPA style reports test statistic, degrees of freedom, exact p-value and effect size, e.g. t(13.46) = 3.42, p = .004, d = 1.71. Examples for every test.
- t-test in SPSSIn SPSS: Analyze → Compare Means → Independent-Samples T Test. Read Levene’s test, then t, df, p and the CI, and report with Cohen’s d in APA style.
- Statistics software comparedSPSS and Stata are menu- or command-based commercial packages, R and Python are free code, JASP and jamovi are free point-and-click. Choose by field and task.