50% lifetime discountCLASSEVA50
The t-test: Worked Examples Step by Step
Subject Mastery

The t-test: Worked Examples Step by Step

By Jonas17 September 202611 min read
Key Takeaways
The t-test examples here cover three types in rising order of difficulty: one-sample, independent two-sample, and paired, each with every calculation shown.
The t-statistic measures how many standard errors the sample mean sits from the null hypothesis value; the larger the absolute value, the stronger the evidence against the null.
Degrees of freedom determine which critical value you compare against: n-1 for one-sample and paired tests; n1+n2-2 for the pooled two-sample test.
The most common exam error is using the wrong standard error formula: individual standard deviation for one-sample tests, pooled standard deviation for two independent groups, and standard deviation of differences for paired designs.
Effect size (Cohen's d) should accompany every t-test conclusion; a statistically significant result with a tiny d has limited practical meaning.

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 typeOne-sample
Data structureOne group; compare to a fixed reference
Example research questionDoes the mean reaction time in this group equal 250 ms?
Test typeIndependent two-sample
Data structureTwo separate, unrelated groups
Example research questionDo Group A and Group B have the same mean exam score?
Test typePaired
Data structureSame subjects measured twice, or matched pairs
Example research questionDid scores improve from pre-test to post-test?

Choosing the wrong test variant is one of the most common errors in statistics coursework.

Which t-test Should You Use?A flowchart starting with the question: how many groups? One group leads to the one-sample t-test. Two groups leads to a second question: are the groups matched or repeated measures? Yes leads to the paired t-test. No leads to the independent two-sample t-test.Which t-test Should You Use?How many groups?Count the distinct measurement groupsOne groupTwo groupsOne-Sample t-testCompare group mean to aknown reference valueAre observations matchedor repeated measures?Same subject under 2 conditions?YesNoPaired t-testAnalyze differences; df = n - 1IndependentTwo-Sample t-testPooled SD; df = n1+n2-2
The correct test variant depends on the data structure, not on the research question alone. Applying a two-sample test to matched pairs throws away the within-subject correlation and reduces power.

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.

t-Distribution with Rejection RegionsA symmetric bell curve representing the t-distribution. Two vertical lines at t = -2.101 and t = +2.101 mark the critical values for a two-tailed test at alpha = 0.05 with df = 18. The tails beyond these lines are shaded red as rejection regions. The centre is shaded green as the non-rejection region.t-Distribution: Two-Tailed Test at alpha = 0.05df = 18, critical value = 2.101-2.101+2.1010Fail to reject H095% of distributionRejectH0RejectH0
The critical value divides the distribution into a non-rejection region (centre, green) and two rejection regions (tails, red). If your calculated t exceeds 2.101 in either direction, you reject H0 at the 5% level. Critical value source: MIT OpenCourseWare Statistics t-tables.

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.

Show the Standard Error Step Separately

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).”

2.258
t-statistic in Example 1
Exceeds the critical value of 2.131 at df = 15, alpha = 0.05 (two-tailed) so H0 is rejected.

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.

Equal Variance Assumption

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.

Two-Sample t-test: Calculation PipelineFive stacked boxes connected by downward arrows. Box 1: State hypotheses and find critical value. Box 2: Compute pooled standard deviation sp. Box 3: Compute standard error SE = sp times sqrt(1/n1 + 1/n2). Box 4: Compute t = (mean1 - mean2) / SE. Box 5: Compare |t| to critical value and decide.Two-Sample t-test: Step-by-Step PipelineStep 1: State H0 and H1, set alpha, find critical valuedf = n1 + n2 - 2; look up t-critical in table or calculatorStep 2: Pooled SD sp = sqrt[((n1-1)s1^2 + (n2-1)s2^2) / (n1+n2-2)]Check variance ratio first; if ratio < 4, pooled test is validStep 3: Standard error SE = sp * sqrt(1/n1 + 1/n2)Write this line separately to earn method marksStep 4: t = (x-bar1 - x-bar2) / SEKeep at least 3 decimal places; do not round earlyStep 5: Compare |t| to critical value; write plain-language conclusionQuote t-value, df, and direction of result in your statement
The pooled standard deviation step (Step 2) is where most errors appear; writing it explicitly before computing the standard error prevents sign or rounding mistakes.

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.

Student1
Pre-workshop score58
Post-workshop score66
Difference (post - pre)8
Student2
Pre-workshop score72
Post-workshop score75
Difference (post - pre)3
Student3
Pre-workshop score65
Post-workshop score71
Difference (post - pre)6
Student4
Pre-workshop score49
Post-workshop score60
Difference (post - pre)11
Student5
Pre-workshop score78
Post-workshop score80
Difference (post - pre)2
Student6
Pre-workshop score55
Post-workshop score64
Difference (post - pre)9
Student7
Pre-workshop score63
Post-workshop score70
Difference (post - pre)7
Student8
Pre-workshop score70
Post-workshop score76
Difference (post - pre)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.

One-Tailed vs Two-Tailed: Choose Before Collecting Data

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.

Paired Differences Dot Plot for Example 3Eight data points plotted horizontally at their difference values: 2, 3, 6, 6, 7, 8, 9, 11. A vertical dashed line marks the mean of 6.5. A shaded band covers the range 3.5 to 9.5, representing one standard deviation (2.976) either side of the mean.Paired Differences: Example 3Post-workshop score minus pre-workshop score for each of 8 students0123456789101112Score difference (post - pre)d-bar = 6.5meansd = 2.976211
All eight differences are positive, confirming the direction of the effect before calculating the t-statistic. The shaded band marks plus and minus one standard deviation around the mean difference of 6.5.

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.

ErrorDividing by s instead of s/sqrt(n)
What happensThe standard error becomes the standard deviation; the t-statistic is inflated by a factor of sqrt(n)
How to avoid itWrite SE as its own line before dividing; label it "standard error" to force yourself to complete the step
ErrorUsing n instead of n-1 for degrees of freedom (one-sample)
What happensYou look up the wrong row in the t-table, producing a different critical value
How to avoid itAlways write df = n - 1 on the page before looking up the table; do not look up critical values until df is written
ErrorRunning a two-sample test on paired data
What happensThe test ignores within-subject correlation; the standard error is too large and the test loses power
How to avoid itCheck whether each observation in group 1 has a natural match in group 2 before choosing the test
ErrorChoosing one-tailed after seeing the data direction
What happensHalves the effective p-value without scientific justification; widely regarded as p-hacking
How to avoid itSpecify 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 Too Early

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.

Open Statistics Calculator

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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.

Related articles

Try a free AI tutoring session