Degrees of freedom are the number of independent values minus the number of quantities estimated from them: n − 1 for a one-sample or paired t-test, n₁ + n₂ − 2 for a pooled two-sample t-test, (r − 1)(c − 1) for a chi-square test of independence, and k − 1 and N − k for one-way ANOVA. Pick your test above and this degrees of freedom calculator applies the right formula, including the Welch–Satterthwaite df for unequal variances.
You need df to look up a critical value in a t, chi-square or F table, or to read the p-value your software prints. Using the wrong df is one of the most common reasons a hand-worked answer doesn’t match the back of the book.
How to use the calculator
- Choose the test: one-sample t, paired t, pooled or Welch two-sample t, chi-square goodness of fit or independence, one-way ANOVA, or linear regression.
- Enter the counts it asks for — sample sizes, categories, rows and columns, groups or predictors. Welch also needs the two sample standard deviations.
- Read the df. ANOVA and regression show every line of the ANOVA table (model, residual, total).
Formulas by test
Which df formula each common test uses, with the reference that states it.
| Test | Degrees of freedom | Source |
|---|---|---|
| One-sample t / confidence interval for a mean | n − 1 | NIST §1.3.5.2 |
| Paired (matched) t-test | n − 1, n = number of pairs | OpenStax §10.4 |
| Two-sample t, equal variances (pooled) | n₁ + n₂ − 2 | NIST §1.3.5.3 |
| Two-sample t, unequal variances (Welch) | Welch–Satterthwaite (below) | NIST §1.3.5.3, OpenStax §10.1 |
| Chi-square goodness of fit | k − 1 (minus estimated parameters) | OpenStax §11.2, NIST §1.3.5.15 |
| Chi-square test of independence | (r − 1)(c − 1) | OpenStax §11.3 |
| One-way ANOVA | k − 1 between, N − k within | OpenStax §13.2 |
| Linear regression (residual) | n − p − 1 | NIST Dataplot RESDF, OpenStax §12.4 |
Why n − 1?
A sample standard deviation is built from the deviations x − x̄. Those deviations always sum to zero, so, as OpenStax explains, once n − 1 of them are known the last is determined. Estimating the mean “uses up” one degree of freedom. The same logic runs through every formula here: each estimated mean, total or parameter removes one.
Welch degrees of freedom (unequal variances)
When the two groups have different spreads, the NIST e-Handbook gives the Welch–Satterthwaite approximation:
df = (s₁²/n₁ + s₂²/n₂)² ÷ [ (s₁²/n₁)² / (n₁ − 1) + (s₂²/n₂)² / (n₂ − 1) ]
It is usually a decimal and smaller than the pooled n₁ + n₂ − 2; it equals the pooled value when the two standard deviations and the two sample sizes are equal (first row below).
| s₁ | n₁ | s₂ | n₂ | Welch df | Pooled df |
|---|---|---|---|---|---|
| 1 | 10 | 1 | 10 | 18 | 18 |
| 1 | 10 | 3 | 10 | 10.98 | 18 |
| 1 | 30 | 3 | 10 | 9.67 | 38 |
| 2 | 15 | 5 | 40 | 52.67 | 53 |
| 5 | 12 | 5 | 30 | 20.33 | 40 |
| 0.866 | 9 | 1 | 16 | 18.85 | 23 |
The last row is OpenStax’s Example 10.1, which reports df ≈ 18.8462 — this calculator gives 18.8466.
Chi-square degrees of freedom
Goodness of fit: df = k − 1, where k is the number of categories. If you estimate parameters of the hypothesised distribution from the same data, subtract those too — NIST writes it as k − c with c = estimated parameters + 1. Testing a fair die (6 faces) gives 5 df; fitting a Poisson distribution to 8 count categories with the mean estimated from the data gives 6.
Test of independence (contingency table): df = (rows − 1)(columns − 1).
| Rows × columns | 2 columns | 3 columns | 4 columns | 5 columns |
|---|---|---|---|---|
| 2 rows | 1 | 2 | 3 | 4 |
| 3 rows | 2 | 4 | 6 | 8 |
| 4 rows | 3 | 6 | 9 | 12 |
| 5 rows | 4 | 8 | 12 | 16 |
ANOVA and regression degrees of freedom
One-way ANOVA with k groups and N observations in total splits N − 1 total df into k − 1 between groups (the F numerator) and N − k within groups (the denominator). With 4 groups of 10: F(3, 36), total 39. The table gives the split for a few common designs with equal group sizes; with unequal groups, N is simply the total count.
| Groups k | Per group | df between | df within | df total |
|---|---|---|---|---|
| 2 | 10 | 1 | 18 | 19 |
| 3 | 10 | 2 | 27 | 29 |
| 3 | 20 | 2 | 57 | 59 |
| 4 | 10 | 3 | 36 | 39 |
| 5 | 8 | 4 | 35 | 39 |
| 6 | 12 | 5 | 66 | 71 |
In linear regression, residual df = observations − estimated parameters. With an intercept and p predictors that is n − p − 1; simple linear regression (one predictor) has n − 2, the df OpenStax uses to test a correlation. With 50 observations and 3 predictors: model 3, residual 46, total 49.
Worked examples
- One-sample t: 20 students’ test scores → df = 19.
- Paired t: blood pressure before and after for 15 people → 15 differences → df = 14.
- Pooled t: 20 vs 25 observations → df = 43.
- Welch t: s₁ = 4.2, n₁ = 20; s₂ = 6.8, n₂ = 25 → df = 40.666 (use 40 in a printed t-table).
- Chi-square independence: 3 age groups × 4 answer choices → df = 6.
Common mistakes
- Paired data treated as two samples. For before/after measurements on the same people, use n pairs − 1, not n₁ + n₂ − 2.
- Counting cells instead of rows and columns. A 3 × 4 table has 12 cells but only 6 df.
- Forgetting estimated parameters in goodness of fit. Estimating a mean from the data costs one more df.
- Swapping the ANOVA df. The F-table numerator is k − 1 (between), the denominator N − k (within).
- Rounding Welch df up. Round down for table lookups, or use the exact value in software.
Describe your data before testing it with the box plot maker (five-number summary and outliers). Read between two rows of a t or chi-square table with the interpolation calculator. Also see the grade calculator and the AP Statistics score calculator.
Frequently asked questions
How do you calculate degrees of freedom?
Start with the number of independent values and subtract one for every quantity you estimate from them. For a one-sample or paired t-test that is n − 1; for a pooled two-sample t-test n₁ + n₂ − 2; for a chi-square test of independence (rows − 1)(columns − 1); for one-way ANOVA k − 1 between and N − k within.
Why is it n − 1 degrees of freedom?
Because the deviations from the sample mean always add to zero. Once you know n − 1 of them, the last one is fixed, so only n − 1 are free to vary (OpenStax §8.2).
What are the degrees of freedom for a two-sample t-test?
With equal variances (pooled), df = n₁ + n₂ − 2 — for 20 and 25 observations, 43. With unequal variances use the Welch–Satterthwaite formula, which gives a smaller, usually non-integer df (40.67 for SDs 4.2 and 6.8).
Can degrees of freedom be a decimal?
Yes, for Welch’s t-test, whose Welch–Satterthwaite formula (NIST e-Handbook §1.3.5.3) rarely gives a whole number. OpenStax’s Example 10.1 (n₁ = 9, s₁ = 0.866; n₂ = 16, s₂ = 1.00) gives df ≈ 18.8466. Software uses the decimal directly; with a printed t-table, round down to the next whole number, which gives a slightly larger critical value.
What are the degrees of freedom for a chi-square test?
Goodness of fit: number of categories − 1 (e.g. a die with 6 faces has 5 df), minus one more for each parameter estimated from the data. Test of independence: (r − 1)(c − 1) — a 2 × 2 table has 1 df and a 3 × 4 table 6.
What are the degrees of freedom for ANOVA?
Between groups (numerator) = k − 1, within groups (denominator) = N − k, total = N − 1. Four groups of 10 give F(3, 36).
What are the degrees of freedom in regression?
Residual df = n − p − 1 for p predictors plus an intercept — observations minus estimated parameters, as NIST Dataplot defines it. Simple linear regression has n − 2 (OpenStax §12.4). With 50 observations and 3 predictors: model df 3, residual df 46, total 49.
What are the degrees of freedom for a paired t-test?
n − 1, where n is the number of pairs (differences), not the total number of measurements. 15 before-and-after pairs give 14 df.
What are degrees of freedom in simple terms?
The number of values in a calculation that are still free to change once the constraints are fixed. They set which t, chi-square or F distribution — and which table row — you use for critical values and p-values.
Sources & method
- NIST/SEMATECH e-Handbook §1.3.5.2 — Confidence limits for the mean (t with N − 1 df)
- NIST/SEMATECH e-Handbook §1.3.5.3 — Two-sample t-test (N₁ + N₂ − 2 and Welch–Satterthwaite df)
- NIST/SEMATECH e-Handbook §1.3.5.15 — Chi-square goodness-of-fit test (k − c df)
- OpenStax Introductory Statistics 2e §8.2 — Student’s t: why df = n − 1
- OpenStax Introductory Statistics 2e §10.1 — Two means, unknown SDs (Welch df, Example 10.1)
- OpenStax Introductory Statistics 2e §10.4 — Matched or paired samples (n − 1)
- OpenStax Introductory Statistics 2e §11.2 — Goodness-of-fit test (k − 1)
- OpenStax Introductory Statistics 2e §11.3 — Test of independence ((r − 1)(c − 1))
- OpenStax Introductory Statistics 2e §13.2 — The F distribution (k − 1 and n − k)
- OpenStax Introductory Statistics 2e §12.4 — Significance of the correlation coefficient (n − 2)
- NIST Dataplot Reference Manual — RESDF (residual df = observations − parameters)
Results are estimates for general information. Found an error? It helps everyone — see our methodology.