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
- Choose one-sample or two-sample.
- 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.