Degrees of Freedom Calculator
A one-sample t test on 25 observations has 24 degrees of freedom, one less than the sample size. This degrees of freedom calculator covers five common statistical tests in one tool: the one-sample t test, the two-sample t test with equal variances assumed, Welch's t test for unequal variances, the chi-square test, and one-way ANOVA. Pick your test type from the dropdown, enter the sample sizes, counts, or standard deviations that test requires, and the calculator returns the degrees of freedom you need to look up a critical value or a p-value. Degrees of freedom is not one fixed formula. It changes shape depending on how many samples you have, how many parameters your test estimates, and how the underlying distribution is built, which is exactly why a five-mode calculator is more useful than five separate memorized formulas.
Quick answer
Degrees of freedom is the number of values in a calculation that are free to vary once you have fixed the sample size and any parameters already estimated from the data.
What this tells you
- •Degrees of freedom is the number of values in a calculation that are free to vary once you have fixed the sample size and any parameters already estimated from the data.
- •A one-sample t test loses one degree of freedom to the sample mean, so df = n - 1.
- •A two-sample t test with equal variances assumed loses two degrees of freedom, one per sample mean, so df = n1 + n2 - 2.
- •Welch's t test, used when the two samples have unequal variances, calculates a non-integer df through the Welch-Satterthwaite equation, then that value is typically floored for a table lookup.
- •A chi-square test on a contingency table uses df = (rows - 1)(cols - 1), while a chi-square goodness-of-fit test uses df = categories - 1.
- •One-way ANOVA reports three degrees of freedom at once: df between groups (k - 1), df within groups (N - k), and df total (N - 1).
How to Use
- 11. Choose your test type from the dropdown: one-sample t test, two-sample t test with equal variances, Welch's t test, chi-square test, or one-way ANOVA.
- 22. Enter the inputs that test requires. The form only shows the fields your selected test needs, so a one-sample test asks for sample size while Welch's test asks for two sample sizes and two standard deviations.
- 33. For the chi-square test, choose whether you are testing a contingency table (enter rows and columns) or a goodness-of-fit test against a single categorical variable (enter the number of categories).
- 44. Read the degrees of freedom result. For Welch's test you get both the raw decimal value and a floored whole number for table lookups. For ANOVA you get all three degrees of freedom at once.
- 55. Take the degrees of freedom into a critical value calculator or a p-value calculator to finish the significance test.
How It Works
Formula
One-sample: df = n - 1. Two-sample (equal variances): df = n1 + n2 - 2. Welch: df = (s1²/n1 + s2²/n2)² / [(s1²/n1)²/(n1-1) + (s2²/n2)²/(n2-1)]. Chi-square: df = (rows - 1)(cols - 1), or df = categories - 1. ANOVA: df_between = k - 1, df_within = N - k, df_total = N - 1.Degrees of freedom counts how many quantities in a statistic are still free to vary after the data has fixed the rest. A one-sample t test estimates one parameter, the sample mean, from n observations, which leaves n - 1 free values, so df = n - 1. A two-sample t test with equal variances assumed pools two samples and estimates two means, which leaves n1 + n2 - 2 free values. Welch's t test drops the equal-variance assumption, so it cannot use that simple subtraction. Instead it approximates an effective degrees of freedom with the Welch-Satterthwaite equation, which weighs each sample's variance-to-size ratio and almost always lands on a decimal rather than a whole number. That decimal is the correct value for a precise p-value, but critical-value tables list whole numbers, so the convention is to floor the Welch df to the next lower integer, a conservative choice that never overstates significance. A chi-square test on a contingency table has (rows - 1)(cols - 1) free cells once the row and column totals are fixed, while a goodness-of-fit chi-square test compares observed counts against categories - 1 free values once the total count is fixed. One-way ANOVA splits total variability into a between-groups component, with k - 1 degrees of freedom for k group means, and a within-groups component, with N - k degrees of freedom for N total observations, and the two always sum to df_total = N - 1.
Calculation note: values are processed in the order shown above, using the current input units.
Worked Examples
One-sample t test with 25 observations
A one-sample t test loses one degree of freedom to the sample mean it estimates, so 25 observations leave 25 - 1 = 24 degrees of freedom.
Two-sample t test with equal variances, n1 = 15 and n2 = 18
Pooling two samples and estimating two means leaves n1 + n2 - 2 degrees of freedom. Here 15 + 18 - 2 = 31.
Welch's t test with unequal variances
The Welch-Satterthwaite equation weighs each sample's variance-to-size ratio, s1²/n1 and s2²/n2. With s1 = 8, n1 = 12, s2 = 15, n2 = 10, the equation returns about 13.167 degrees of freedom. The calculator reports that raw decimal for precise p-value calculations and floors it to 13 for looking up a critical value in a standard t table.
Chi-square test on a 3-by-4 contingency table
A contingency table with fixed row and column totals leaves (rows - 1)(cols - 1) free cells. Here (3 - 1)(4 - 1) = 2 × 3 = 6.
One-way ANOVA with 4 groups and 40 total observations
Between-groups df is k - 1, so 4 - 1 = 3. Within-groups df is N - k, so 40 - 4 = 36. Total df is N - 1, so 40 - 1 = 39, and 3 + 36 also equals 39, confirming the split.
Degrees of Freedom by Test Type
The formula each test type uses and what it requires as input.
| Test Type | Formula | Requires | Example df |
|---|---|---|---|
| One-sample t test | df = n - 1 | n ≥ 2 | n = 25 → df = 24 |
| Two-sample t test (equal variances) | df = n1 + n2 - 2 | n1, n2 ≥ 2 | 15, 18 → df = 31 |
| Welch's t test (unequal variances) | Welch-Satterthwaite equation | s1, s2 > 0 and n1, n2 ≥ 2 | 8, 12, 15, 10 → df ≈ 13.167 |
| Chi-square (contingency table) | df = (rows - 1)(cols - 1) | rows, cols ≥ 2 | 3, 4 → df = 6 |
| Chi-square (goodness-of-fit) | df = categories - 1 | categories ≥ 2 | 6 → df = 5 |
| One-way ANOVA | df_between = k - 1, df_within = N - k | k ≥ 2 and N > k | 4, 40 → 3 and 36 |
Welch's df is left as a decimal for exact p-value work and floored to a whole number only when you need to read a printed critical-value table.
Why degrees of freedom changes shape by test
Degrees of freedom is not a single formula you memorize once. It measures how many independent pieces of information remain in your data after the test has used some of that information to estimate its own parameters. A t distribution, a chi-square distribution, and an F distribution each get their exact shape from a degrees-of-freedom value, so plugging the wrong df into a lookup table changes the critical value and can flip a significance decision even when every other number in your analysis is correct.
The t test family shows this most clearly. A one-sample test estimates a single mean, so it spends one degree of freedom and keeps n - 1. A two-sample test with equal variances assumed pools both samples and estimates two means, spending two degrees of freedom for n1 + n2 - 2. Welch's test refuses to pool the variances at all, which is more realistic when your two groups have genuinely different spreads, but it pays for that realism with a messier, non-integer degrees-of-freedom formula that has to be approximated rather than counted directly.
Chi-square and ANOVA follow a different logic again. A chi-square contingency table's degrees of freedom comes from how many cells you could still choose freely if you already know every row total and column total, which is why it multiplies (rows - 1) by (cols - 1) rather than subtracting a flat constant. ANOVA reports three degrees-of-freedom values because it partitions total variability into two independent sources, between groups and within groups, and each source gets its own df that must add up to the total.
Common mistakes
- Using the equal-variance formula (n1 + n2 - 2) when the two samples have clearly different spreads. Welch's test exists for that case, and using the wrong df can understate or overstate significance.
- Rounding Welch's decimal degrees of freedom instead of flooring it. The standard convention floors the value for table lookups, which is more conservative than rounding to the nearest whole number.
- Mixing up rows and columns in a chi-square contingency table, or forgetting to subtract 1 from each dimension before multiplying.
- Reporting only df_between or only df_within for an ANOVA result. Both values are required to read an F table, since the F distribution takes a numerator df and a denominator df.
- Treating degrees of freedom as always equal to sample size. It equals sample size only when zero parameters are estimated from the data first, which almost never happens in a real hypothesis test.
- Entering the population standard deviation instead of the sample standard deviation into Welch's formula. Welch's equation is built around sample variances, s1² and s2², not population variances.
Embed this calculator on your site
Drop this single line where you want the calculator to appear. It is responsive, mobile-friendly, resizes automatically, and is free to use with attribution.
<script src="https://calctide.com/embed.js" data-tool="degrees-of-freedom-calculator" async></script>Preview the embed at /embed/degrees-of-freedom-calculator/.