Omni Calculator logo
Board

Degrees of Freedom Calculator

This degrees of freedom calculator will help you determine this crucial variable for one-sample and two-sample t-tests, chi-square tests, and ANOVA. Read the text to find out:

  • What degree of freedom is (degrees of freedom definition);
  • How to find degrees of freedom;
  • The degrees of freedom formula; and
  • How to calculate degrees of freedom by hand.

What are degrees of freedom? Definition

The definition of degrees of freedom is as follows:

Degrees of freedom indicate the number of independent pieces of information used to calculate a statistic; in other words, they represent the maximum number of independent values that are free to vary in a dataset. This is generally calculated by subtracting one from the sample size. It is important for validating statistical tests such as chi-square tests, ANOVA tests, t-tests, and F-tests.

The number of degrees of freedom for a statistic varies based on the sample size:

  • If the sample size (n) is small, then the degrees of freedom will also be small.

  • If the sample size (n) is large, then the degrees of freedom will also be large.

Now that we know what degrees of freedom are, let’s learn how to find df.

💡 The concept of degrees of freedom is connected to sample size, but it is not the same. The degrees of freedom are always fewer than the sample size

How to find degrees of freedom – formulas

The formula for degrees of freedom depends on the type of statistical test you're performing. Below, you'll see equations for the most popular ones:

  1. 1-sample t-test:

    df=N1\textrm{df} = N - 1

    where:

    • df\textrm{df} – Degrees of freedom; and

    • NN – Total number of subjects/values.

  2. 2-sample t-test (samples with equal variances):

    df=N1+N22\textrm{df} = N_1 + N_2 - 2

    where:

    • N1N_1 – Number of values from the first sample; and

    • N2N_2 – Number of values from the second sample.

  3. 2-sample t-test with unequal variances (Welch’s t-test):

    In this case, we calculate an approximation of the degrees of freedom:

df=(Var1N1+Var2N2)2Var12N12(N11)+Var22N22(N21)\qquad \textrm{df} = \frac{\left(\frac{\textrm{Var}_1}{N_1}+ \frac{\textrm{Var}_2}{N_2}\right)^2}{\frac{\textrm{Var}_1^2}{N_1^2 (N_1-1)}+\frac{\textrm{Var}_2^2}{N_2^2 (N_2-1)}}

where Var\rm Var – Variance.

✅ As you can see, the number of values in samples heavily influences the number of degrees of freedom. Learn more with our sample size calculator. Or, if you just wish to perform a t-test quickly and without worrying about df, use Omni's t-test calculator – it will take care of everything!

  1. ANOVA:

    • Degrees of freedom between groups:

      dfbetween=k1\textrm{df}_{\rm between} = k - 1

      where kk – Number of groups or cell means.

    • Degrees of freedom within groups:

      dfwithin=Nk\textrm{df}_{\rm within} = N - k

    • Total degrees of freedom:

      dftotal=N1\textrm{df}_{\rm total} = N - 1

  2. Chi-squared test of independence

    df=(rows1)×(columns1)\textrm{df} = (\textrm{rows} - 1) \times (\textrm{columns} - 1)

You can discover more about computing χ² with our dedicated chi squared calculator.

If you're wondering how to find df\rm df quickly – use our degrees of freedom calculator. It includes all of the above formulas.

Example: How to calculate degrees of freedom by hand?

In this section, we’ll solve some examples and understand how to find the degrees of freedom for different statistical tests.

Example 1:

Imagine we have two numbers: x, y, and the mean of those numbers: m. How many degrees of freedom do we have in this data set of three variables? The answer is 2. Why? Because 2 is the number of values that can change. If you choose the values of any two variables, the third one is already determined. Look:

  • If x equals 2 and y equals 4, you can’t pick any mean you like; it’s already determined:

    m = (x + y) / 2

    m = (2 + 4) / 2

    m = 3

  • If you assign 3 to x and 6 to m, then y’s value is “automatically” set – it’s not free to change because:

    m = (x + y) / 2

    6 = (3 + y) / 2

    12 = 3 + y

    12 − 3 = y

    y = 9

Any time you assign some two values, the third has no “freedom to change”. Hence, there are two degrees of freedom in our scenario.

Example 2:

Let's calculate the degree of freedom for the provided sample: 15, 46, 67, 23, 45.

  1. Determine the size of your sample: N = 5

  2. Subtract 1 from the sample size to get the degree of freedom. Given N = 5:

    df = N - 1

    df = 5 - 1 = 4

  3. Thus, the df of the given sample is 4.

Example 3:

Evaluate the degree of freedom for the provided sample data:

N1: 1, 7, 5, 12, 17

N2: 14, 15, 21, 29

  1. Determine the size of both observations: N1 = 5 and N2 = 4

  2. Because they are two sequences, apply a 2-sample t-test:

    df = N1 + N2 - 2

    df = 5 + 4 - 2 = 7

  3. That's it! The degree of freedom is 7.

Degrees of freedom calculator

This is how to use the df calculator:

  1. Choose the statistical test you're using.

  2. Enter the variables which will appear in the rows below, e.g. the sample size.

  3. You'll find the result in the last box of the df calculator.

FAQs

How to calculate degrees of freedom for t-test?

To calculate degrees of freedom of a 1-sample t-test:

  1. Determine the size of your sample (N).

  2. Subtract 1.

  3. The result is the number of degrees of freedom.

How to calculate degrees of freedom for chi-square?

To calculate degrees of freedom for the chi-square test, use the following formula:

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

That is:

  1. Count the number of rows in the chi-square table and subtract one.

  2. Count the number of columns and subtract one.

  3. Multiply the number from step 1 by the number from step 2.

How to calculate degrees of freedom for two-sample t-test?

To calculate degrees of freedom for two-sample t-test, use the following formula:

df = N₁ + N₂ − 2

That is:

  1. Determine the sizes of your two samples.

  2. Add them up.

  3. Add -2 to the result from the previous step.

How to calculate degrees of freedom for ANOVA?

To calculate degrees of freedom for ANOVA:

  1. Subtract 1 from the number of groups to find degrees of freedom between groups.

  2. Subtract the number of groups from the total number of subjects to find degrees of freedom within groups.

  3. Subtract 1 from the total number of subjects (values) to find total degrees of freedom.

Can degrees of freedom be 0?

Yes, theoretically degrees of freedom can equal 0. It would mean there's one piece of data with no "freedom" to vary and no unknown variables. However, in practice, you shouldn't have 0 degrees of freedom when performing statistical tests.

Did we solve your problem today?

Check out 28 similar inference, regression, and statistical tests calculators 📉

Absolute uncertainty

AB test

Bonferroni correction