Skip to content
CoursesLog in
← Statistics glossary

degrees of freedom (df)

The number of values free to vary once the estimated quantities are fixed, e.g. n - 1 for one sample, n1 + n2 - 2 for a two-sample t-test.

Degrees of freedom (df) count how many values in your calculation are genuinely free to vary once something has already been fixed by the data. The classic illustration: if you know that five numbers average 40, you can pick any four of them, but the fifth is then forced, because the total must be 200. Five values, one constraint, four degrees of freedom.

That is exactly why the sample variance divides by n−1n - 1 instead of nn:

s2=∑(xi−xˉ)2n−1s^2 = \frac{\sum (x_i - \bar{x})^2}{n - 1}

The deviations are measured from the sample mean xˉ\bar{x}, which was itself computed from the same data, so they always sum to zero and only n−1n - 1 of them carry independent information. Dividing by nn would systematically underestimate the spread, badly so in small samples.

Every test that estimates something from the data "spends" degrees of freedom, and the formula depends on the test:

Test
Degrees of freedom
one-sample or paired t-test
n−1n - 1
two-sample t-test (pooled)
n1+n2−2n_1 + n_2 - 2
chi-square test on an r×cr \times c table
(r−1)(c−1)(r - 1)(c - 1)
one-way ANOVA
k−1k - 1 between groups, N−kN - k within

Why it matters in practice: df pick which curve you compare your statistic against. With few df the t-distribution has fatter tails than the normal, so the critical value is larger and you need a stronger signal to reject H0. As df grow, the t-distribution approaches the normal and its two-tailed 5% critical value approaches 1.96. Software computes df for you; your job is to know that small df means a stricter bar.

Example

Where the "minus one" comes from. CatChow's new pickup point logged orders over 5 days, averaging 40 a day, so the total is 200. Pick any four days: 38, 45, 36 and 42, which sum to 161. The fifth day is no longer free: 200−161=39200 - 161 = 39. Five values, four degrees of freedom.

Now the variance of these five days. Deviations from the mean of 40: −2,5,−4,2,−1-2, 5, -4, 2, -1 (they sum to 0, as they always must). Squared: 4+25+16+4+1=504 + 25 + 16 + 4 + 1 = 50.

  • Dividing by n−1=4n - 1 = 4: s2=12.5s^2 = 12.5, so s≈3.54s \approx 3.54 orders.
  • Dividing by n=5n = 5 would give 10, an underestimate of the true day-to-day spread.

In a t-test. The upsell-widget test compared 10 control orders with 10 variant orders, so df=10+10−2=18df = 10 + 10 - 2 = 18. The two-tailed critical value at α=0.05\alpha = 0.05 is 2.101. With only 5 orders per group, df=8df = 8 and the bar rises to 2.306; with huge samples it falls to 1.96.

In a chi-square test. Marketing compares conversion across 3 ad channels, with 2 outcomes each (converted or not). The table is 3×23 \times 2, so df=(3−1)(2−1)=2df = (3 - 1)(2 - 1) = 2, and the 5% critical value of chi-square is 5.99.

Common mistakes

  • Using the total sample size as df. A two-sample t-test with 10 + 10 users has 18 df, not 20; a chi-square table's df depend on rows and columns, not on the number of users.
  • Looking up the normal 1.96 for a small-sample t-test. With 8 df the correct bar is 2.306; using 1.96 makes false positives more likely.
  • Dividing by n when computing a sample SD by hand. Spreadsheets differ (STDEV.S uses n−1n - 1, STDEV.P uses nn); for a sample, use the n−1n - 1 version.
  • Being puzzled by fractional df. Welch's t-test adjusts df for unequal variances and often reports values like 14.7; that is expected.
  • Thinking more df means a bigger effect. Df only reflect how much information went into the estimate, not how large or important the difference is.

Learn it in the course