
The t-test: Worked Examples Step by Step
The t-test examples that trip up most students in Statistics are not the formula itself but the moment before the formula: choosing the right variant, framing the hypotheses precisely, and matching the degrees of freedom to the design. Get those three decisions right and the arithmetic follows a clear template. This post works through three progressively harder problems, showing every step so you can track where the numbers come from rather than just copying a final answer.
What Is the t-test?
The t-test is a statistical hypothesis test that evaluates whether a sample mean (or the difference between means) differs from a reference value by more than random sampling variation would predict. It produces a t-statistic, a standardized distance expressed in standard error units. That statistic is then compared to a critical value from the t-distribution to decide whether to reject the null hypothesis.
William Sealy Gosset published the test in 1908 under the pseudonym “Student” while working at Guinness Brewery, which is why it is sometimes called Student's t-test. His goal was to draw reliable conclusions from small samples, a problem he encountered in quality control. The test remains one of the most widely taught in introductory statistics because it handles real-world sample sizes cleanly.
One-Sample, Two-Sample, and Paired: Which to Use
The three variants answer three different questions. A one-sample t-test asks whether a single group's mean differs from a known or hypothesized value (for example, whether a batch's mean weight matches the labeled specification). An independent two-sample t-test compares the means of two separate, unrelated groups (for example, whether students taught by method A score differently from students taught by method B). A paired t-test compares measurements taken from the same subjects under two conditions, or from matched pairs, so each participant serves as their own control.
| Test type | Data structure | Example research question |
|---|---|---|
| One-sample | One group; compare to a fixed reference | Does the mean reaction time in this group equal 250 ms? |
| Independent two-sample | Two separate, unrelated groups | Do Group A and Group B have the same mean exam score? |
| Paired | Same subjects measured twice, or matched pairs | Did scores improve from pre-test to post-test? |
Choosing the wrong test variant is one of the most common errors in statistics coursework.
Hypotheses and the Decision Rule
Every t-test begins with two hypotheses. The null hypothesis (H0) states there is no difference: the population mean equals the reference value, or the two group means are equal. The alternative hypothesis (H1) states a difference exists and can be two-tailed (any direction) or one-tailed (a specific direction). Two-tailed tests are standard unless theory or prior evidence justifies a directional prediction.
The decision rule compares the absolute value of the calculated t-statistic to the critical value. If |t| exceeds the critical value, reject H0. If not, fail to reject H0. “Fail to reject” is not the same as proving H0 true; it means the data do not provide sufficient evidence against it at the chosen significance level.
Example 1: One-Sample t-test (Simple)
A sports science researcher claims that the average resting heart rate in a population of trained athletes is 58 beats per minute (bpm). You collect data from a random sample of 16 athletes. The sample mean is 61.5 bpm and the sample standard deviation is 6.2 bpm. Test at the 5% significance level whether the population mean differs from 58 bpm.
Setting Up the Problem
The design fits a one-sample t-test: one group, compared to a fixed reference value (58 bpm). State the hypotheses explicitly before calculating anything:
- H0: mu = 58 bpm (the population mean equals 58)
- H1: mu ≠ 58 bpm (the population mean differs from 58; two-tailed)
- Significance level: alpha = 0.05
- Degrees of freedom: df = n - 1 = 16 - 1 = 15
The critical value for a two-tailed test at alpha = 0.05 with df = 15 is 2.131 (from a t-table or the statistics calculator). You will reject H0 if |t| > 2.131.
Working Through the Calculation
The one-sample t-formula is:
t = (x-bar - mu0) / (s / sqrt(n))
Substituting the values: the standard error is s / sqrt(n) = 6.2 / sqrt(16) = 6.2 / 4 = 1.55. Then t = (61.5 - 58) / 1.55 = 3.5 / 1.55 = 2.258.
Examiners award marks for method, not just the final t-value. Write the standard error computation on its own line before substituting. A student who writes SE = 6.2 / sqrt(16) = 1.55 and then t = 3.5 / 1.55 = 2.26 picks up method marks even if a rounding error appears at the final step. Collapsing everything into one line sacrifices those marks.
Making the Decision
The calculated t-statistic is 2.258. The critical value for df = 15 at alpha = 0.05 (two-tailed) is 2.131. Because |2.258| > 2.131, you reject H0.
Write the conclusion in plain language: “There is sufficient evidence at the 5% significance level to conclude that the mean resting heart rate in this population of trained athletes (estimated 61.5 bpm) differs significantly from 58 bpm (t(15) = 2.258, p < 0.05).”
Example 2: Independent Two-Sample t-test
Two groups of undergraduate students complete a memory task. Group A (n = 12) studies with spaced practice; Group B (n = 11) studies with massed practice. Group A scores a mean of 74.3 with standard deviation 8.1. Group B scores a mean of 67.9 with standard deviation 9.4. Assume equal population variances. Test at the 5% level whether the two groups differ in mean score.
Problem Setup and Assumptions
This fits an independent two-sample t-test: two separate groups of different participants. State the hypotheses:
- H0: mu1 = mu2 (population means are equal)
- H1: mu1 ≠ mu2 (population means differ; two-tailed)
- Significance level: alpha = 0.05
- Degrees of freedom: df = n1 + n2 - 2 = 12 + 11 - 2 = 21
The critical value for df = 21 at alpha = 0.05 (two-tailed) is 2.080.
The pooled two-sample t-test assumes the two population variances are approximately equal. A rough check compares the ratio of the larger to the smaller sample variance. Here: (9.4)^2 / (8.1)^2 = 88.36 / 65.61 = 1.35. A ratio below 4 is generally acceptable for the pooled test with roughly equal sample sizes. If variances are clearly unequal, use Welch's t-test, which adjusts the degrees of freedom.
Pooled Standard Deviation and the Test Statistic
The pooled standard deviation (sp) combines variance estimates from both samples, weighted by their degrees of freedom:
sp = sqrt[ ((n1-1) * s1^2 + (n2-1) * s2^2) / (n1+n2-2) ]
Substituting: sp = sqrt[ (11 * 65.61 + 10 * 88.36) / 21 ] = sqrt[ (721.71 + 883.6) / 21 ] = sqrt[ 1605.31 / 21 ] = sqrt[76.443] = 8.743.
The test statistic formula for two independent groups uses this pooled estimate:
t = (x-bar1 - x-bar2) / (sp * sqrt(1/n1 + 1/n2))
Substituting: the standard error term is 8.743 * sqrt(1/12 + 1/11) = 8.743 * sqrt(0.0833 + 0.0909) = 8.743 * sqrt(0.1742) = 8.743 * 0.4173 = 3.649. Then t = (74.3 - 67.9) / 3.649 = 6.4 / 3.649 = 1.754.
Conclusion and Interpretation
The calculated t-statistic is 1.754. The critical value for df = 21 at alpha = 0.05 (two-tailed) is 2.080. Because |1.754| < 2.080, you fail to reject H0.
Plain-language conclusion: “At the 5% significance level, there is insufficient evidence to conclude that spaced and massed practice groups differ in mean memory score (t(21) = 1.754, p > 0.05).” Note that failing to reject H0 does not confirm the groups are identical; the sample was small and the 6.4-point observed difference may reflect a real but undetected effect. This is where effect size adds crucial context.
Example 3: Paired t-test (Exam-Level)
Eight university students complete a statistics module. Their scores on a practice test before a revision workshop and after the workshop are shown below. Test at the 5% level whether the workshop produced a significant improvement in scores. Assume normality of differences.
| Student | Pre-workshop score | Post-workshop score | Difference (post - pre) |
|---|---|---|---|
| 1 | 58 | 66 | 8 |
| 2 | 72 | 75 | 3 |
| 3 | 65 | 71 | 6 |
| 4 | 49 | 60 | 11 |
| 5 | 78 | 80 | 2 |
| 6 | 55 | 64 | 9 |
| 7 | 63 | 70 | 7 |
| 8 | 70 | 76 | 6 |
Raw scores before and after a statistics revision workshop. The difference column is the key input for the paired t-test.
Computing the Differences
The paired t-test works entirely on the column of differences. Compute the mean and standard deviation of those eight difference values.
Differences: 8, 3, 6, 11, 2, 9, 7, 6. Sum = 52. Mean difference (d-bar) = 52 / 8 = 6.5.
Standard deviation of differences (sd): compute each squared deviation from 6.5, then find the sample variance. Deviations from 6.5: 1.5, -3.5, -0.5, 4.5, -4.5, 2.5, 0.5, -0.5. Squared deviations: 2.25, 12.25, 0.25, 20.25, 20.25, 6.25, 0.25, 0.25. Sum of squared deviations = 62. Sample variance = 62 / (8-1) = 62 / 7 = 8.857. Standard deviation sd = sqrt(8.857) = 2.976.
Test Statistic and Critical Value
The paired t-test uses the same one-sample formula applied to the differences:
t = d-bar / (sd / sqrt(n))
State the hypotheses. This is a directional test because the question asks about “improvement”:
- H0: mu_d = 0 (no mean difference; workshop has no effect)
- H1: mu_d > 0 (mean difference is positive; one-tailed)
- Degrees of freedom: df = n - 1 = 8 - 1 = 7
The critical value for a one-tailed test at alpha = 0.05 with df = 7 is 1.895 (from the OpenStax Introductory Statistics t-tables).
Standard error of differences: se_d = sd / sqrt(n) = 2.976 / sqrt(8) = 2.976 / 2.828 = 1.052. Then t = 6.5 / 1.052 = 6.179.
Because 6.179 > 1.895, reject H0. The workshop produced a statistically significant improvement at the 5% level (t(7) = 6.179, p < 0.05, one-tailed).
Effect Size and What It Adds
Cohen's d for a paired test is d = d-bar / sd = 6.5 / 2.976 = 2.18. By Cohen's (1988) benchmarks, d = 0.2 is small, 0.5 is medium, and 0.8 is large. A d of 2.18 indicates an exceptionally large effect. The statistical significance in this example was never in doubt with a t of over 6; the effect size quantifies just how large the improvement was, which matters as much as whether it reached significance.
A one-tailed test at alpha = 0.05 has a less stringent critical value than a two-tailed test at the same alpha level. Choosing one-tailed after seeing the data to make a borderline result significant is a form of p-hacking. The direction of the alternative hypothesis must be justified by prior theory or research before you look at the data, not by the direction the data happened to go.
Four Errors That Cost Marks on Exam Problems
Reviewing student work in statistics courses reveals four procedural errors that recur across t-test practice problems. Each one costs marks not because the algebra is wrong but because the method is applied incorrectly.
| Error | What happens | How to avoid it |
|---|---|---|
| Dividing by s instead of s/sqrt(n) | The standard error becomes the standard deviation; the t-statistic is inflated by a factor of sqrt(n) | Write SE as its own line before dividing; label it "standard error" to force yourself to complete the step |
| Using n instead of n-1 for degrees of freedom (one-sample) | You look up the wrong row in the t-table, producing a different critical value | Always write df = n - 1 on the page before looking up the table; do not look up critical values until df is written |
| Running a two-sample test on paired data | The test ignores within-subject correlation; the standard error is too large and the test loses power | Check whether each observation in group 1 has a natural match in group 2 before choosing the test |
| Choosing one-tailed after seeing the data direction | Halves the effective p-value without scientific justification; widely regarded as p-hacking | Specify the alternative hypothesis direction before calculating anything |
These four errors appear in a substantial proportion of marked statistics coursework. Each is avoidable with a consistent notation habit.
Rounding the pooled standard deviation to one decimal place before computing the standard error compounds the error across subsequent steps. Keep at least three decimal places in all intermediate values. The final answer may be rounded to two or three decimal places, but intermediate calculations should stay precise. A student who writes sp = 8.743 and SE = 3.649 shows correct method; a student who rounds sp to 8.7 early produces SE = 3.63, which shifts the final t-statistic by enough to matter near a critical boundary.
Checking Your Work with a Statistics Calculator
Once you understand the mechanics of each t-test variant through the worked examples above, a statistics calculator lets you verify your hand calculations quickly and explore how changing sample sizes or variances shifts the result.
Statistics Calculator
Enter your data to compute t-statistics, degrees of freedom, p-values, and confidence intervals for one-sample, two-sample, and paired t-tests.
The subject calculators hub also covers hypothesis testing for other distributions (chi-square, F-test) that appear alongside the t-test in statistics courses. Use the calculator to confirm critical values for any combination of df and alpha level rather than relying on partial t-tables printed in textbooks.
For further worked problems covering related statistical methods, the hypothesis testing guide walks through the general framework that applies across all significance tests, not just the t-test. The u-substitution worked examples post applies the same step-by-step approach to calculus integration for students covering multiple quantitative modules. You can also explore all subject-specific tools from the university resources hub.
The MIT OpenCourseWare Statistics for Applications course provides complete lecture notes and problem sets that place the t-test in its broader context among parametric tests. OpenStax Introductory Statistics (free, peer-reviewed) covers the same material with additional practice problems and t-table appendices.
To practice t-test problems with guided step checking and instant feedback on where your method breaks down:
Key Takeaways
- The t-test examples here cover three variants: the one-sample test compares one group to a fixed reference; the independent two-sample test compares two unrelated groups using a pooled standard deviation; the paired test compares matched or repeated observations using the standard deviation of differences.
- The t-statistic measures how many standard errors the observed mean (or mean difference) sits from the null hypothesis value. A larger absolute t-statistic provides stronger evidence against H0.
- Degrees of freedom determine the critical value: df = n-1 for one-sample and paired tests; df = n1+n2-2 for the pooled two-sample test. Writing df explicitly before consulting the t-table prevents the most common lookup error.
- The pooled two-sample test assumes approximately equal population variances. Check this with a variance ratio before applying the pooled formula; use Welch's version when variances differ substantially.
- Effect size (Cohen's d) should accompany every t-test result. A statistically significant finding with d = 0.1 may be practically trivial; a non-significant result with d = 0.6 in a small sample may be worth investigating further with more data.
- One-tailed tests require directional justification before data collection, not after. Selecting the direction based on the observed sample mean inflates the Type I error rate and invalidates the inferential framework.
- The most common calculation errors are dividing by s rather than s/sqrt(n) for the standard error, and rounding intermediate values too aggressively. Write the standard error as a labelled line before computing t.
For more on the inferential framework that connects the t-test to regression, chi-square, and ANOVA, the monetary vs. fiscal policy worked examples post shows the same graded approach applied to economics reasoning, and the grade calculators hub helps you track which modules need the most attention as finals approach.


