⚡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, independence or single variance, the F-test for two variances, one-way or two-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, two-way ANOVA, the F-test and regression show every line you need for an F-table lookup.

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
Chi-square test for one varianceN − 1NIST §1.3.5.8
F-test for two variancesN₁ − 1 and N₂ − 1NIST §1.3.5.9
One-way ANOVAk − 1 between, N − k withinOpenStax §13.2
Two-way ANOVA (balanced)I − 1, J − 1, (I − 1)(J − 1), IJ(K − 1)NIST §3.2.3.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.

Variance tests: chi-square and F

Tests on spread use the same “one df per estimated quantity” logic. The chi-square test for a single variance compares a sample variance with a hypothesised value using T = (N − 1)(s/σ₀)² on N − 1 df; NIST’s worked example uses 100 gear diameters, so 99 df. The F-test for two variances divides one sample variance by the other, F = s₁² ÷ s₂², and needs two df: N₁ − 1 for the numerator and N₂ − 1 for the denominator. Order matters — swap the samples and you swap the df, so keep the numerator sample first. NIST’s example has 240 observations in each group, F(239, 239).

Two-way ANOVA degrees of freedom

With two factors crossed in a balanced design — I levels of A, J levels of B and K replicates in each cell — the NIST e-Handbook two-way ANOVA table splits the IJK − 1 total df into four lines. Each F ratio uses its own line as the numerator and the error line as the denominator. Example: 3 fertilisers × 4 watering schedules, 5 plants per combination.

Two-way ANOVA df, 3 × 4 design with 5 per cell
SourceFormuladf
Factor A (rows)I − 12
Factor B (columns)J − 13
Interaction A × B(I − 1)(J − 1)6
Error (residual)IJ(K − 1)48
TotalIJK − 159

The four lines add up to the total, which is a quick check on hand work. With only one observation per cell (K = 1) the formula gives zero error df, so there is nothing left to test the interaction against — you need replicates to estimate an interaction and its error separately.

Using df with a t-table

Once you have df, read across that row of a critical-value table. These are two values from the NIST t-distribution table: the one-sided 0.95 column (a two-sided 90% interval) and the 0.975 column (two-sided 95%).

Student’s t critical values by degrees of freedom (NIST)
df0.95 (90% two-sided)0.975 (95% two-sided)
101.8122.228
201.7252.086
301.6972.042
401.6842.021
601.6712.000
1001.6601.984
∞ (normal)1.6451.960

Fewer df means a fatter-tailed distribution and a larger critical value, so small samples need stronger evidence. If your df falls between printed rows, round down, or interpolate: halfway between the 30 and 40 rows gives 2.0315, close to the exact 35-df value of 2.030.

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 the degrees of freedom for an F-test of two variances?

Numerator df = N₁ − 1 and denominator df = N₂ − 1, where sample 1 supplies the variance on top of the ratio F = s₁² ÷ s₂² (NIST e-Handbook §1.3.5.9). NIST’s example with 240 observations in each sample uses F(239, 239).

What are the degrees of freedom for a two-way ANOVA?

For I levels of factor A, J levels of factor B and K observations per cell: A has I − 1, B has J − 1, the interaction (I − 1)(J − 1), error IJ(K − 1) and total IJK − 1 (NIST e-Handbook §3.2.3.2). A 3 × 4 design with 5 per cell gives 2, 3, 6 and 48 (total 59).

What happens to the t-distribution as degrees of freedom increase?

It gets closer to the normal distribution. In NIST’s t-table the two-sided 95% critical value falls from 2.228 at 10 df to 2.042 at 30, 1.984 at 100 and 1.960 at infinity, the normal value.

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