Confidential, authorship-first academic support

The t-Test Explained: Formula, Types and Interpretation

A t-test compares a mean (or a difference between means) with what the null hypothesis predicts, using the test statistic t = observed difference / standard error. You compare that t value with a t distribution with the right degrees of freedom to get a p-value. This guide gives the formula for the t statistic for one-sample, independent (Student and Welch) and paired t-tests, shows how to find the degrees of freedom, works through a numeric example of each, and shows how to report the result in APA style.

  • 13-minute read
  • Updated
On this page

What is a t-test?

A t-test is a hypothesis test that asks whether a difference between means is larger than you would expect from sampling noise alone. It does this by converting the difference into a single number, the t statistic, and comparing that number with the t distribution, a bell-shaped curve with heavier tails than the normal distribution.

Definition of the t statistic: the t statistic is the observed difference divided by its estimated standard error. In words, it tells you how many standard errors your result sits away from the value stated in the null hypothesis. A t of 0 means your data match the null exactly; a t of 3 or −3 means the result is three standard errors away, which is rarely produced by chance when the null is true.

There are three common versions, and choosing the right one depends on your design:

TypeQuestion it answersExample
One-sample t-testDoes one group's mean differ from a fixed reference value?Do students sleep less than the recommended 8 hours?
Independent-samples t-test (Student or Welch)Do two separate groups have different means?Do students taught with method A score higher than those taught with method B?
Paired-samples t-testDid the same people (or matched pairs) change between two measurements?Did anxiety scores drop from before to after a workshop?

If you have three or more groups, a t-test is the wrong tool; use ANOVA instead. Our guide to choosing a statistical test walks through that decision.

Statistics hypothesis testing in five steps

Every t-test follows the same logic used across statistics hypothesis testing. Understanding it once makes every other test easier to learn.

  1. State the hypotheses. The null hypothesis (H0) is the "no effect" position, for example μ = 8 or μ1 = μ2. The alternative hypothesis (H1) is what you suspect instead: μ ≠ 8 (two-tailed) or μ < 8 (one-tailed).
  2. Choose the significance level (α). The level of significance is the probability of rejecting H0 when it is actually true (a Type I error) that you are willing to accept. It is usually set at .05 before you see the data.
  3. Calculate the test statistic. For a t-test this is the t value, computed from your sample mean(s), standard deviation(s) and sample size(s).
  4. Find the p-value or critical value. Using the degrees of freedom, look up how extreme your t is under the null. Software reports the exact p-value.
  5. Decide and interpret. If p ≤ α, or equivalently if the absolute test statistic is greater than the critical value, reject H0. Then describe the size and direction of the effect, not just the verdict.

What does the level of significance mean in hypothesis testing?

Setting α = .05 means that if the null hypothesis were true and you repeated the study many times, about 5% of those studies would produce a "significant" result purely by chance. It is a threshold for the decision rule, not the probability that your hypothesis is true. A p-value of .03 says: if H0 were true, data at least this extreme would occur about 3% of the time.

Why significance alone is not enough

A tiny, unimportant difference can be statistically significant in a very large sample, and a meaningful difference can miss significance in a small one. That is why current reporting standards ask for an effect size and a confidence interval alongside every test statistic, a point we return to below.

The t statistic formula for each type of t-test

All three formulas share one structure: t = (observed difference − hypothesized difference) / standard error. What changes is how the difference and the standard error are calculated.

One-sample t-test formula

t = (x̄ − μ0) / (s / √n)

where x̄ is the sample mean, μ0 is the reference value from the null hypothesis, s is the sample standard deviation, and n is the sample size. The denominator, s / √n, is the standard error of the mean.

Independent-samples t-test formula (Student, equal variances assumed)

t = (x̄1 − x̄2) / (sp × √(1/n1 + 1/n2)) sp² = [(n1 − 1)s1² + (n2 − 1)s2²] / (n1 + n2 − 2)

sp is the pooled standard deviation: a weighted average of the two group variances, then square-rooted. Pooling is only justified if the two population variances are similar.

Welch's t-test formula (equal variances not assumed)

t = (x̄1 − x̄2) / √(s1²/n1 + s2²/n2)

This is the two sample t-test standard deviation formula most statisticians now recommend by default, because it keeps each group's own variance rather than pooling them. When the two groups have the same size, the Student and Welch t values are identical; only the degrees of freedom differ.

Paired-samples t-test formula

t = d̄ / (sd / √n)

Here you first compute a difference score for each pair (d = before − after), then d̄ is the mean of those differences, sd is their standard deviation, and n is the number of pairs. A paired t-test is really a one-sample t-test on the difference scores with μ0 = 0.

How to find degrees of freedom for a t-test

Degrees of freedom (df) tell you which t distribution to use. With few degrees of freedom the t distribution has fat tails, so you need a larger t to reach significance; as df grows, the t distribution approaches the standard normal. For example, the two-tailed critical value at α = .05 is 2.571 with 5 df, 2.262 with 9 df, 2.086 with 20 df and 2.000 with 60 df, closing in on the normal value of 1.96.

TestDegrees of freedom
One-sample t-testdf = n − 1
Paired t-testdf = n − 1, where n is the number of pairs
Independent t-test (Student)df = n1 + n2 − 2
Welch's t-testdf = (s1²/n1 + s2²/n2)² / [ (s1²/n1)² / (n1 − 1) + (s2²/n2)² / (n2 − 1) ]
t-test for a Pearson correlationdf = n − 2
t-test for a regression coefficientdf = n − k − 1, where k is the number of predictors

The Welch formula (the Welch–Satterthwaite approximation) usually gives a non-integer df, such as 12.60. That is correct; report it to two decimals rather than rounding to a whole number.

Why subtract 1? Once you have used the data to estimate the mean, only n − 1 of the values are free to vary; the last one is fixed by the requirement that deviations sum to zero. Each additional estimated parameter costs another degree of freedom.

Worked example: one-sample t-test

A researcher records the nightly sleep of 10 students and wants to know whether they sleep less than the recommended 8 hours. The hours are: 7.2, 6.8, 7.5, 8.1, 6.9, 7.0, 7.8, 6.5, 7.3, 7.1.

  1. Hypotheses: H0: μ = 8; H1: μ ≠ 8 (two-tailed), α = .05.
  2. Mean: x̄ = 72.2 / 10 = 7.22 hours.
  3. Standard deviation: the sum of squared deviations from 7.22 is 2.056, so s = √(2.056 / 9) = 0.478.
  4. Standard error: s / √n = 0.478 / √10 = 0.151.
  5. Test statistic: t = (7.22 − 8) / 0.151 = −5.16.
  6. Degrees of freedom: df = 10 − 1 = 9. The critical value is ±2.262.
  7. Decision: |−5.16| > 2.262, so reject H0. The exact p-value is about .0006.

The 95% confidence interval for the mean is 7.22 ± 2.262 × 0.151, or 6.88 to 7.56 hours. Because the interval excludes 8, it tells the same story as the test, and it also shows how far below 8 the true mean plausibly lies.

Worked example: independent-samples t-test (Student and Welch)

Two sections of a course are taught with different methods. Exam scores:

  • Method A (n1 = 8): 78, 85, 82, 90, 74, 88, 81, 86. Mean = 83.0, s1 = 5.318, s1² = 28.286.
  • Method B (n2 = 10): 72, 75, 80, 68, 77, 74, 79, 71, 70, 76. Mean = 74.2, s2 = 3.938, s2² = 15.511.

The difference in means is 83.0 − 74.2 = 8.8 points. H0: μ1 = μ2; H1: μ1 ≠ μ2; α = .05.

Student's t-test (pooled variance)

  1. Pooled variance: sp² = [(7 × 28.286) + (9 × 15.511)] / 16 = (198.0 + 139.6) / 16 = 21.10, so sp = 4.593.
  2. Standard error: 4.593 × √(1/8 + 1/10) = 4.593 × 0.474 = 2.179.
  3. t = 8.8 / 2.179 = 4.04, with df = 8 + 10 − 2 = 16.
  4. Critical value at df = 16 is 2.120; 4.04 exceeds it, p ≈ .001. Reject H0.

95% CI for the difference: 8.8 ± 2.120 × 2.179, or 4.18 to 13.42 points.

Welch's t-test (separate variances)

  1. Variance components: s1²/n1 = 28.286 / 8 = 3.536 and s2²/n2 = 15.511 / 10 = 1.551.
  2. Standard error: √(3.536 + 1.551) = √5.087 = 2.255.
  3. t = 8.8 / 2.255 = 3.90.
  4. df = (3.536 + 1.551)² / [3.536² / 7 + 1.551² / 9] = 12.60.
  5. Critical value at df = 12.60 is about 2.167; p ≈ .002. Reject H0.

Both versions agree here. Welch's test gives a slightly smaller t and fewer degrees of freedom because group A is both smaller and more variable. When group sizes and variances differ a lot, the two tests can disagree, and Welch's is the safer choice.

Worked example: paired-samples t-test

Eight participants complete an anxiety scale before and after a study-skills workshop.

Participant12345678
Before2430273522293126
After2027253021242825
Difference (d)43251531
  1. Mean difference: d̄ = 24 / 8 = 3.0 points.
  2. Standard deviation of differences: sum of squared deviations from 3.0 is 18, so sd = √(18 / 7) = 1.604.
  3. Standard error: 1.604 / √8 = 0.567.
  4. t = 3.0 / 0.567 = 5.29, df = 8 − 1 = 7.
  5. Critical value at df = 7 is 2.365; p ≈ .001. Reject H0.

95% CI for the mean change: 3.0 ± 2.365 × 0.567, or 1.66 to 4.34 points. Notice the power of pairing: each person serves as their own control, so stable differences between people (some are simply more anxious) drop out of the error term. Analyzing these same numbers as two independent groups would throw that advantage away and give a much smaller t.

Assumptions of the t-test and what to do when they fail

  • Continuous outcome. The dependent variable should be measured on an interval or ratio scale (scores, times, amounts).
  • Independence. Observations must not influence one another. In an independent t-test, nobody appears in both groups; in a paired test, the pairs are independent of other pairs.
  • Approximate normality. For the one-sample and independent tests, the outcome should be roughly normal within each group; for the paired test, the difference scores should be. The t-test is fairly robust to mild non-normality, especially with 30 or more per group. See our guide to the normal distribution for ways to check.
  • Equal variances (Student's test only). The pooled test assumes both populations have the same variance. Welch's test drops this assumption, which is why many statisticians use it by default rather than relying on a preliminary Levene's test.
  • No extreme outliers. A single extreme value can inflate the standard deviation and distort the mean. Check boxplots before testing.

If normality is badly violated in a small sample, consider a nonparametric alternative: the Wilcoxon signed-rank test (instead of one-sample or paired) or the Mann–Whitney U test (instead of independent). A transformation of the outcome (for example, a log for right-skewed reaction times) or a bootstrap confidence interval are other options.

Effect size for a t-test: Cohen's d

The t statistic mixes the size of an effect with the sample size, so it is not a measure of how large or important the difference is. Report a standardized effect size as well.

TestCohen's d formulaValue in our examples
One-sampled = (x̄ − μ0) / s(7.22 − 8) / 0.478 = −1.63
Independentd = (x̄1 − x̄2) / sp8.8 / 4.593 = 1.92
Paireddz = d̄ / sd3.0 / 1.604 = 1.87

Cohen's rough benchmarks are 0.2 (small), 0.5 (medium) and 0.8 (large), but they are only a fallback; interpret d against what is typical and meaningful in your field. With small samples, Hedges' g applies a correction that shrinks d slightly (for the independent example, g ≈ 1.82). For paired designs, say which version of d you used, because dz can differ noticeably from a d based on the pre-test standard deviation.

How to report a t-test in APA style

APA style reports the test statistic with its degrees of freedom in parentheses, the exact p-value and an effect size, and gives the descriptive statistics so readers can see the direction of the effect. Italicize t, p, M, SD and d; give t to two decimals; drop the leading zero for p; and write p < .001 when it is smaller than .001.

One-sample:

Students slept less than the recommended 8 hours (M = 7.22, SD = 0.48), t(9) = −5.16, p < .001, d = −1.63, 95% CI [6.88, 7.56].

Independent (Welch):

Students taught with method A scored higher (M = 83.0, SD = 5.32) than those taught with method B (M = 74.2, SD = 3.94), Welch's t(12.60) = 3.90, p = .002, d = 1.92.

Paired:

Anxiety scores fell from before (M = 28.0, SD = 4.14) to after the workshop (M = 25.0, SD = 3.38), t(7) = 5.29, p = .001, dz = 1.87, 95% CI for the mean change [1.66, 4.34].

State whether the test was one- or two-tailed if it was not two-tailed, and name the version of the independent test you ran. In a results chapter, describe the statistic in context rather than stacking numbers; our guide to data analysis in research covers writing up results more broadly.

The t statistic in regression and correlation, and running it in software

The same "estimate divided by standard error" idea appears well beyond comparing means:

  • t stat in regression: each coefficient is tested with t = b / SE(b), with df = n − k − 1. A t of 2.5 for a predictor means its estimated slope is 2.5 standard errors away from zero.
  • Correlation coefficient: to test whether a Pearson r differs from zero, t = r√(n − 2) / √(1 − r²), with df = n − 2. For r = .45 with n = 22, t = .45 × √20 / √(1 − .2025) = 2.25, df = 20, p ≈ .036.

Running a t-test in Stata, SPSS and R

TestStataR
One-samplettest sleep == 8t.test(sleep, mu = 8)
Student (pooled)ttest score, by(method)t.test(score ~ method, var.equal = TRUE)
Welchttest score, by(method) unequalt.test(score ~ method)
Pairedttest before == aftert.test(before, after, paired = TRUE)

Note the defaults: R runs Welch's test unless you ask otherwise, while Stata's ttest pools variances unless you add unequal. In SPSS, all three tests are under Analyze > Compare Means, and the independent-samples output shows rows for both "equal variances assumed" and "not assumed" (Welch). For more Stata syntax, including tabstat for descriptives and graph commands for boxplots, see our Stata commands guide.

Frequently asked questions

What is the formula for the t statistic?

In general, t = (observed value − hypothesized value) / standard error. For a one-sample test that is t = (x̄ − μ0) / (s / √n); the independent and paired versions change how the difference and standard error are calculated.

How do you find degrees of freedom for a t-test?

Use n − 1 for a one-sample or paired test (n = number of pairs) and n1 + n2 − 2 for Student's independent test. Welch's test uses the Welch–Satterthwaite formula, which usually gives a non-integer value.

What does it mean if the test statistic is greater than the critical value?

If the absolute value of t is greater than the critical value for your α and degrees of freedom, the result falls in the rejection region, so you reject the null hypothesis. This is equivalent to p being smaller than α.

Should I use Student's or Welch's t-test?

Welch's test is the safer default because it does not assume equal population variances and loses very little power when variances are in fact equal. Student's pooled test is fine when group sizes and variances are similar.

What is a good t value?

There is no fixed good value; significance depends on the degrees of freedom and α. As a rough guide, with large samples an absolute t above about 1.96 is significant at the .05 level (two-tailed), but you should always report the p-value and effect size.

Can a t-test be used with small samples?

Yes, the t-test was designed for small samples, but with very small samples it relies more heavily on the normality assumption. Check the data for skew and outliers, and consider a nonparametric test if normality is clearly violated.

What is the difference between a t-test and a z-test?

A z-test uses a known population standard deviation and the normal distribution, while a t-test estimates the standard deviation from the sample and uses the t distribution. In practice the population standard deviation is rarely known, so the t-test is far more common.

Related help and guides

Statistics

SPSS help

Run the right test, read the output and report it correctly.

Guide

Which Statistical Test Should I Use?

Choose the right statistical test by research question, variable type and design: t-tests, ANOVA, chi-square, correlation, regression and more.

Guide

The Normal Distribution Explained

The normal distribution formula, the standard normal distribution and z-scores, the 68-95-99.7 rule and how to check normality, with worked examples.

Guide

Descriptive vs Inferential Statistics

The difference between descriptive and inferential statistics, with examples of mean, median, mode, standard deviation, confidence intervals and common tests.

Want expert feedback on your own work?

Tell us what you’re working on and where you’re stuck. We’ll suggest the right kind of help and send a clear quote, and you stay the author.

WhatsApp us