Degrees of Freedom Calculator
Calculate degrees of freedom for any statistical test. Enter your sample sizes and parameters, and see the exact formula with your numbers substituted in.
§1 Reference: Degrees of Freedom Formulas
Every statistical test has a unique degrees of freedom formula. Use this table to find the formula for your test, or see the "How this was calculated" section above for your specific numbers.
| Test | Formula | What it means |
|---|---|---|
| One-sample t-test | df = n − 1 |
Number of observations minus 1, because you estimated the sample mean. |
| Independent t-test (equal variances) |
df = n₁ + n₂ − 2 |
Combined sample size minus 2 (one for each estimated mean). |
| Welch t-test (unequal variances) |
df = (s₁²/n₁ + s₂²/n₂)² ÷ [(s₁²/n₁)²/(n₁−1) + (s₂²/n₂)²/(n₂−1)] |
Satterthwaite approximation; accounts for unequal variances. Result is typically fractional. |
| Paired t-test | df = n − 1 |
Number of pairs minus 1 (applies to the differences, not the raw data). |
| One-way ANOVA | df between = k − 1 |
Between = groups minus 1. Within = total observations minus groups. Total = sum of between and within. |
| Chi-square test of independence |
df = (r − 1)(c − 1) |
Rows minus 1, times columns minus 1. Equals the number of cells you can fill freely. |
| Chi-square goodness of fit |
df = k − 1 − m |
Categories minus 1, minus the number of parameters you estimated from the data (usually 0). |
| Simple linear regression |
df regression = 1 |
Regression always has 1 degree of freedom (one predictor). Residual = total minus regression. Total = n minus 1. |
Welch's degrees of freedom is fractional — keep the decimal
The Welch–Satterthwaite formula produces a non-integer result. Do not round or floor it. Modern statistical software (R, SPSS, Python) all accept fractional degrees of freedom. Your calculator above will show the exact decimal value, which is what you use for critical values and p-values.
§2 Worked Example: Welch's t-test Degrees of Freedom
Welch's test is the one most students struggle with by hand, because the formula looks complex. Here's a complete worked example.
Setup
You have two independent groups with unequal variances:
- Sample 1: n₁ = 12, s₁ = 3.5
- Sample 2: n₂ = 8, s₂ = 2.1
Calculation
Step 1: Calculate the numerator. This is the squared sum of the variance components:
Substitute:
Simplify:
Step 2: Calculate the denominator. This is the weighted sum of squared variance components, each divided by its degrees of freedom:
Substitute:
Simplify:
Step 3: Divide.
The degrees of freedom for this Welch t-test is 17.90 (not rounded to 18). Use this value to look up your critical t-value or calculate your p-value.
§3 Assumptions & When These Tests Apply
One-sample t-test
Assumes observations are independent, from a normal distribution (or n is large). The formula df = n − 1 does not change; what matters is whether the test is valid for your data.
Independent t-test with equal variances
Assumes both groups are sampled from normal distributions with equal population variances. If variances are unequal, use Welch's test instead. This test is less common in practice than Welch's.
Welch's t-test (unequal variances)
Assumes normal distributions but does not assume equal variances. This is the safer default when you are uncertain. The Satterthwaite degrees of freedom is slightly lower than the pooled formula, reflecting the cost of not assuming equal variances.
Paired t-test
Assumes the differences (not the raw values) are approximately normal, and observations are independent. The degrees of freedom are based on the number of pairs, not the number of individual values.
One-way ANOVA
Assumes observations are independent, groups are normally distributed with equal variances, and groups are random samples. The "between" degrees of freedom = k − 1 only depends on the number of groups; the "within" degrees of freedom = N − k depends on total sample size and group count.
Chi-square tests
For independence: assumes independent observations with a large enough sample (expected frequencies ≥ 5 in most cells). For goodness of fit: assumes you know the expected frequencies (or can estimate them from the data). The degrees of freedom reflect the number of cell counts you can choose freely before the rest are determined by row and column totals.
Simple linear regression
Assumes observations are independent, the relationship is linear, and residuals are normally distributed with constant variance. The degrees of freedom are fixed: 1 for regression (one slope), n − 2 for residuals (n observations minus 2 parameters: intercept and slope).
§4 FAQ
What are degrees of freedom in plain English?
Degrees of freedom is the number of values in a calculation that are free to vary. If you know the total of a set of numbers and all but one of them, the last one is fixed — you have lost one degree of freedom. In statistics, every time you estimate a parameter (like a mean), you lose one degree of freedom, because that constraint reduces the number of independent pieces of information left in your data.
Why is it n − 1 and not n?
Because you used one piece of information from your sample (the sample mean) to set up the test. Once you know the mean and all but one of the values, the last value is determined. So you have n − 1 independent pieces of information left. This is why the t-distribution with df = n − 1 is fatter (has heavier tails) than the normal distribution—it accounts for the extra uncertainty of estimating the mean from a small sample.
What are degrees of freedom for a chi-square test?
In a chi-square test, degrees of freedom equals the number of cell frequencies you can fill in freely before the rest are determined by the row and column totals. For independence tests: df = (rows − 1) × (columns − 1). For goodness of fit: df = (categories − 1) − (parameters estimated from data). The intuition is the same: each constraint (knowing a total, estimating a parameter) reduces the degrees of freedom by 1.
What are degrees of freedom for ANOVA?
In one-way ANOVA, there are two degrees of freedom: between-groups df = k − 1 (number of groups minus 1), and within-groups df = N − k (total observations minus number of groups). The between-groups df reflects how many group means you can set freely; the within-groups df reflects the independent variability left after accounting for group membership. They sum to N − 1, the total degrees of freedom.
Why is Welch's degrees of freedom not a whole number?
Welch's t-test uses the Satterthwaite approximation to compute degrees of freedom, which accounts for unequal variances by weighting each sample's contribution separately. This weighted calculation typically produces a decimal value. That's not a sign of an error—modern software handles fractional degrees of freedom precisely, using the continuous gamma function to evaluate the t-distribution. The result is often more accurate than rounding to the nearest integer.
Do I need to memorize these formulas?
No. The point of this calculator is to help you understand and apply the right formula to your data. What matters is knowing which test is appropriate for your research question. Once you pick the test, the formula is something you can look up (or use a tool like this). What you should remember is the conceptual idea: degrees of freedom = sample size minus the number of parameters you estimated.
§5 Cross-linked Tools
Degrees of freedom are a building block for several other calculations:
- t-test calculator — uses degrees of freedom to compute the t-statistic and p-value
- ANOVA calculator — uses between and within degrees of freedom for the F-statistic
- Chi-square calculator — uses degrees of freedom to find the p-value from the chi-square distribution
- Linear regression calculator — uses residual degrees of freedom to estimate standard errors
§6 Sources
- NIST/SEMATECH e-Handbook of Statistical Methods — t-test and degrees of freedom fundamentals
- UCLA OARC Statistical Methods and Data Analytics — hypothesis testing and degrees of freedom context
- OpenStax Introductory Statistics 2e — t-test theory and one-sample df = n − 1
- Welch's t-test (Wikipedia) — Satterthwaite approximation and unequal-variance t-test theory