Statistics

Degrees of Freedom Calculator

Find degrees of freedom for a one-sample or two-sample statistical test.


Degrees of Freedom Calculator

Advertisement

Find the degrees of freedom (df) for a one-sample or two-sample statistical test — the number you look up in a t-table or feed into a stats package alongside a test statistic.

How it works

For a one-sample test, df = n − 1. For a two-sample test with pooled variance, df = n₁ + n₂ − 2 — one degree is “used up” estimating each sample’s own mean.

What this does not include

This covers the two most common cases. It doesn’t cover the Welch-Satterthwaite approximation used for two-sample tests with unequal variances, which produces a non-integer df through a more complex formula.

How to use this calculator

  1. Choose one-sample or two-sample.
  2. Enter the sample size (or both sample sizes).

A worked example

A one-sample test with n=25: degrees of freedom = 25 − 1 = 24.

A two-sample test with n1=15 and n2=20: degrees of freedom = (15−1)+(20−1) = 33.

What the variables mean

Variable Meaning
n Sample size (first sample, for two-sample tests)
n2 Second sample size, for two-sample tests only

Edge cases worth knowing

Degrees of freedom is always one less than sample size, for each sample. A two-sample test combines both samples’ individual reductions rather than treating the pooled data as one group.

A sample size of zero makes degrees of freedom meaningless, so the calculator declines to show a result for that input.

Why does df matter for a t-test?

Degrees of freedom determine the exact shape of the t-distribution used to find a p-value — a t-statistic of 2.0 means something different at df=5 than at df=50.

Why is it n − 1 and not just n?

Once you’ve calculated a sample’s mean, only n − 1 of the data points are still “free” to vary — the last one is determined by the requirement that they all average to that mean.

What does df look like for a chi-square test?

Chi-square tests use a different formula, typically (rows − 1) × (columns − 1) for a contingency table, which isn’t one of the two cases this calculator covers.

Be the first to rate this

Written by

J. Adeyemi

Statistics writer

J. Adeyemi writes the statistics and probability calculators, from descriptive summaries through to distributions and conditional probability. The recurring theme is scope: each page states precisely which question it answers, because most statistical mistakes come from applying a correct formula to the wrong question. Related-but-different measures get separate pages rather than being quietly merged.

Reviewed by

K. Novak

Calculator reviewer — statistics

K. Novak reviews the statistics and probability calculators, checking formula correctness and the scope boundary each page draws around itself. Closely related measures are routinely confused with one another, so review confirms that a page computing one of them says clearly that it is not computing the others.

How we write and review

Related calculators