⚡FreeFastCalculatorAll calculators

Degrees of Freedom Calculator

How to calculate degrees of freedom for one-sample, paired, pooled and Welch t-tests, chi-square goodness of fit and independence, ANOVA and regression.

Updated · Written and fact-checked by the FreeFast editorial team · Free, no sign-up

Degrees of freedom (n − 1)19

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

  1. 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.
  2. Enter the counts it asks for — sample sizes, categories, rows and columns, groups or predictors. Welch also needs the two sample standard deviations.
  3. 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.

TestDegrees of freedomSource
One-sample t / confidence interval for a meann − 1NIST §1.3.5.2
Paired (matched) t-testn − 1, n = number of pairsOpenStax §10.4
Two-sample t, equal variances (pooled)n₁ + n₂ − 2NIST §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 fitk − 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 ANOVAk − 1 between, N − k withinOpenStax §13.2
Linear regression (residual)n − p − 1NIST 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 dfPooled df
1101101818
11031010.9818
1303109.6738
21554052.6753
51253020.3340
0.866911618.8523

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 × columns2 columns3 columns4 columns5 columns
2 rows1234
3 rows2468
4 rows36912
5 rows481216

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 kPer groupdf betweendf withindf total
21011819
31022729
32025759
41033639
5843539
61256671

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

Results are estimates for general information. Found an error? It helps everyone — see our methodology.

Related calculators