Degrees of Freedom Calculator — t-Test, Chi-Square, ANOVA & Regression

Degrees of Freedom Calculator

Pick your test, enter the sample sizes or table dimensions, and get the degrees of freedom, the formula behind them, and the critical value at your significance level.

Degrees of freedom are the independent pieces of information left in your data

Choose a test to see its formula.

Leave blank if you only need the degrees of freedom.

How to Use This Calculator

  1. Choose the test from the dropdown. The formula for that test appears at the top of the calculator.
  2. Enter what the test needs: the sample size for a one-sample or paired t-test, both sample sizes for a two-sample t-test, the number of rows and columns for a chi-square test of independence, the number of groups and total observations for ANOVA, or the number of observations and predictors for regression.
  3. For a Welch t-test, also enter the spread of each group. You can give a standard deviation or a variance.
  4. Pick a significance level to get the critical value. Optionally enter your test statistic to get a p-value.
  5. Press Calculate Degrees of Freedom. Use the degrees of freedom to look up a critical value in a table, or read it directly from this page.

What Are Degrees of Freedom?

A degrees of freedom calculator determines the number of independent values that can vary in a statistical analysis. Degrees of freedom depend on sample size, statistical test, and estimated parameters. For a one-sample t-test, the formula is df = n − 1, where n represents sample size. A sample of 20 observations has 19 degrees of freedom.

Each parameter you estimate from the data, such as a sample mean, uses up one degree of freedom, so df is the number of independent observations minus the number of parameters estimated along the way.

A quick example: three numbers with a mean of 3. Pick the first two freely, say 2 and 4, and the third must be 3 to keep the mean at 3. Only two of the three values were free, so df = 3 − 1 = 2. Degrees of freedom decide which t, chi-square, or F distribution applies to your test statistic, and therefore your critical value and p-value.

N − 1

One estimated mean leaves one fewer free value.

df < N

Degrees of freedom are always smaller than the sample size.

Shape

Fewer df give heavier tails and larger critical values.

Definition reference: Wikipedia — Degrees of freedom (statistics).

Degrees of Freedom Formulas

One-sample or paired t-test

df = N − 1

N is the number of values, or the number of pairs in a paired test.

Two-sample t-test, equal variances

df = N₁ + N₂ − 2

Two means are estimated, so two df are lost.

Chi-square test of independence

df = (rows − 1) × (columns − 1)

Row and column totals are fixed.

Welch's t-test (unequal variances)

df = (s₁²/N₁ + s₂²/N₂)² ÷ [ (s₁²/N₁)²/(N₁ − 1) + (s₂²/N₂)²/(N₂ − 1) ]

The Welch–Satterthwaite approximation. It is usually not a whole number and never exceeds N₁ + N₂ − 2.

Chi-square goodness-of-fit test

df = k − 1 − m

k is the number of categories and m the number of parameters estimated from the data.

Linear regression

dfresidual = n − p − 1, dfmodel = p

p predictors plus the intercept use p + 1 df. Total df = n − 1.

One-way ANOVA

dfbetween = k − 1, dfwithin = N − k, dftotal = N − 1

k is the number of groups and N the total number of observations. The F statistic uses (k − 1, N − k).

ANOVA degrees of freedom: Penn State STAT 500 — One-way ANOVA table.

Worked Example 1: One Sample

You measure five values: 15, 46, 67, 23, and 45. For a one-sample t-test, N = 5.

  • df = N − 1 = 5 − 1 = 4.
  • At α = 0.05 (two-tailed), the critical t-value for 4 df is 2.7764.

Worked Example 2: Two Samples

Sample 1 is 1, 7, 5, 12, 17 (N₁ = 5) and sample 2 is 14, 15, 21, 29 (N₂ = 4). Assume equal variances.

  • df = N₁ + N₂ − 2 = 5 + 4 − 2 = 7. The two-tailed critical value at α = 0.05 is 2.3646.

Worked Example 3: Unequal Variances (Welch)

Group 1 has N₁ = 8 and s₁ = 7.5. Group 2 has N₂ = 25 and s₂ = 2.5. The smaller group is far more variable.

  • s₁²/N₁ = 56.25 ÷ 8 = 7.0313 and s₂²/N₂ = 6.25 ÷ 25 = 0.25.
  • df = (7.0313 + 0.25)² ÷ [7.0313²/7 + 0.25²/24] = 7.504, far below the pooled value of 31.
  • The critical value is 2.3328 instead of 2.0395. Using the pooled df here would make the test too liberal.

Worked Example 4: Chi-Square Table and ANOVA

  • Chi-square: a table with 3 rows and 4 columns has df = (3 − 1) × (4 − 1) = 6. The critical χ² at α = 0.05 is 12.5916.
  • ANOVA: 4 groups and 40 observations give df between = 3, df within = 36, and df total = 39. The critical F(3, 36) at α = 0.05 is 2.8663.
  • Regression: 50 observations and 3 predictors leave 50 − 3 − 1 = 46 residual df.

Degrees of Freedom by Test

Which formula goes with which distribution.

TestDegrees of freedomDistributionExample
One-sample t-testN − 1tN = 20 → 19
Paired t-testN − 1 (N pairs)t12 pairs → 11
Two-sample t-test, equal variancesN₁ + N₂ − 2t15 and 18 → 31
Welch's t-testWelch–Satterthwaitet (fractional df)Often 7.504 instead of 31
Chi-square test of independence(r − 1)(c − 1)χ²3 × 4 table → 6
Chi-square goodness-of-fitk − 1 − mχ²6 categories, 0 estimated → 5
One-way ANOVAk − 1 and N − kF4 groups, N = 40 → 3 and 36
Linear regressionn − p − 1t (coefficients), F (model)n = 50, p = 3 → 46

Goodness-of-fit degrees of freedom (k − c): NIST/SEMATECH e-Handbook — Chi-square goodness-of-fit test.

How Degrees of Freedom Change the Critical t-Value

Two-tailed critical values of the t-distribution. They shrink toward the normal values (1.96 and 2.576) as df grows.

Degrees of freedomα = 0.05α = 0.01
112.706263.6567
24.30279.9248
52.57064.0321
102.22813.1693
202.08602.8453
302.04232.7500
602.00032.6603
1201.97992.6174
∞ (normal)1.96002.5758

With 1 df you need a t statistic above 12.7 to be significant at the 5% level. With 30 df the bar is 2.04. Past about 120 df, the t-distribution is practically the normal distribution.

Frequently Asked Questions

What are degrees of freedom?

Degrees of freedom are the number of independent pieces of information that go into a statistic. Every parameter you estimate from the data, such as a mean, removes one. That is why the degrees of freedom are usually the sample size minus the number of estimated parameters, and always fewer than the sample size. A hypothesis test needs them to pick the right distribution when it compares your sample with the population it came from. Geometrically, they are the dimension of the space in which your data are still free to move.

How do I calculate degrees of freedom for a t-test?

For a one-sample or paired t-test, subtract 1 from the sample size: df = N − 1. For a two-sample t-test with equal variances, add the two sample sizes and subtract 2: df = N₁ + N₂ − 2. If the variances are unequal, use Welch's formula, which weighs each sample's standard deviation and gives a smaller, usually fractional, value. The same rules apply whether you compare your sample with a population mean or with a second sample.

How do I find the degrees of freedom for a chi-square test?

For a test of independence on a contingency table, multiply the number of rows minus 1 by the number of columns minus 1. A 3 × 4 table has (3 − 1)(4 − 1) = 6 df. For a goodness-of-fit test, use k − 1 − m, where k is the number of categories and m is the number of parameters you estimated from the data. A six-sided die has k = 6, one category per face. The result tells the hypothesis test which chi-square distribution to use.

How do I calculate degrees of freedom for ANOVA?

One-way ANOVA has three: between groups k − 1, within groups N − k, and total N − 1, where k is the number of groups and N the total number of observations. The between and within values add up to the total. Each sum of squares is divided by its degrees of freedom, and the F statistic is compared with an F-distribution that uses the first two. The between-groups value k − 1 is the numerator degrees of freedom, and the within-groups value N − k is the denominator degrees of freedom, also called the error degrees of freedom. The group is the independent variable and the measurement is the dependent variable.

Why is it N − 1 and not N?

Because the sample mean is calculated from the same data. Once the mean is fixed, only N − 1 of the values can vary freely, and the last one is determined. The deviations from the sample mean always add to zero, which is exactly one constraint. The same reasoning is why a sample variance and standard deviation divide by N − 1, which corrects the bias you would get when estimating a population variance from a sample.

Can degrees of freedom be a decimal?

Yes. Welch's t-test and some mixed-model tests produce fractional degrees of freedom, because each group's variance is estimated separately. Software uses the exact decimal. If you read from a printed t-table, round down to the nearest row, which gives a slightly conservative critical value.

Can degrees of freedom be zero or negative?

Zero would mean nothing is left free to vary, for example a t-test on a single observation. There is no usable test in that case, so this calculator asks for at least one degree of freedom. A negative value means you are estimating more parameters than you have data points, which is a sign of an overfitted model or a data entry error. In regression, the residual degrees of freedom are n − p − 1, because every coefficient, including the intercept, uses one. Adding independent variables until nothing is left over lets the model fit the dependent variable perfectly but proves nothing, and if some variables are redundant, the rank of the design matrix is lower than its number of columns, so not every coefficient can be estimated.

How do degrees of freedom affect the p-value?

They set the shape of the reference distribution. With few degrees of freedom the t-distribution has heavier tails, so the same t statistic gives a larger p-value and the critical value is higher. As the degrees of freedom grow, the t-distribution approaches the normal distribution. For chi-square and F tests, the degrees of freedom move the whole curve: the chi-square distribution shifts to the right and becomes more symmetric as they grow, so you cannot compare a statistic without them.

Other Useful Calculators

Disclaimer: This calculator is for educational and informational use. It gives the degrees of freedom for common textbook designs. Complex designs, such as mixed models, repeated measures, or multi-way ANOVA, use other formulas. Critical values and p-values for very large degrees of freedom (above 100,000) use a normal approximation. For clinical, regulatory, or other consequential research, consult a qualified statistician.

Last updated: October 10, 2026