What degrees of freedom means
Degrees of freedom (df) is the number of values in a statistical calculation that are free to vary once you impose the constraints the method requires. If you have a sample of n numbers and you fix their mean, only n − 1 of them can take any value you like — the last one is forced, because the deviations from the mean must add up to zero. That single lost degree of freedom is why the sample variance divides by n − 1 rather than n (Bessel's correction), and it is why almost every basic test loses one degree of freedom for each parameter it estimates from the data.
Degrees of freedom matter because they select the exact shape of the reference distribution you use to turn a test statistic into a p-value or a critical value. A t-distribution with 5 df has much heavier tails than one with 50 df; a chi-square distribution with 1 df looks nothing like one with 10 df. Get df wrong and you read the wrong row of the table, which can flip a result from "significant" to "not."
The formulas this calculator uses
- One-sample or paired t-test: df = n − 1, where n is the number of observations (or the number of paired differences). A paired test treats each pair's difference as a single value, so 20 pairs give df = 19.
- Two-sample t-test (pooled, equal variances): df = n₁ + n₂ − 2, because two group means are estimated. For Welch's unequal-variance t-test the df is smaller and non-integer (the Welch–Satterthwaite approximation, which needs the two sample variances); this tool covers the standard pooled case.
- Chi-square goodness-of-fit: df = k − 1, where k is the number of categories. Subtract one more df for each additional parameter you estimate from the data (for example, df = k − 2 if you fit a Poisson mean before testing).
- Chi-square test of independence: df = (r − 1)(c − 1) for an r × c contingency table.
- One-way ANOVA: between-groups df = k − 1, within-groups (error) df = N − k, and total df = N − 1, where k is the number of groups and N is the total number of observations. Note that (k − 1) + (N − k) = N − 1, so the two component df always add to the total.
Worked examples
- A one-sample t-test on 25 measurements: df = 25 − 1 = 24.
- A two-sample t-test comparing groups of 15 and 12: df = 15 + 12 − 2 = 25.
- A goodness-of-fit test across 6 categories: df = 6 − 1 = 5.
- A 3 × 4 contingency table: df = (3 − 1)(4 − 1) = 2 × 3 = 6.
- One-way ANOVA with 4 groups and 40 total observations: between df = 3, within df = 36, total df = 39.