Skip to main content

Degrees of Freedom: Definition, Meaning, and Examples

Discover the hidden constraint behind every statistical test and learn to interpret your results with real confidence.
Feb 9, 2026  · 5 min read

Degrees of freedom are one of those statistical terms that often sound abstract or confusing at first. You may already have heard this term in a textbook somewhere.

The short answer is that degrees of freedom measure how much freedom your data has to vary once certain restrictions, like a fixed mean or total, are imposed. If that sounds confusing, don’t worry: In this article, starting with the next section, I will elaborate in detail. I will explain why they exist, and I will provide clear examples so you can study them and build a rigorous intuition.

What Do We Mean by Degrees of Freedom?

Degrees of freedom represent the number of values in a dataset or calculation that can vary freely once all constraints have been accounted for.

Imagine you are asked to pick three numbers that add up to exactly 30.  You can freely choose the first two numbers, but the third number is automatically fixed to make the total 30. This reduces the number of values that are truly free to vary. Therefore, degrees of freedom tell us how many independent pieces of information are left after applying the restrictions.

How to Find Degrees of Freedom

In general, degrees of freedom are calculated as the number of observations n minus the number of constraints or parameters estimated from the data.

Different statistical tests apply different constraints, which is the reason why the formulas vary, like in the case of n-1 for a single sample t-test. In practice, you rarely need to calculate degrees of freedom manually, as statistical software does this automatically. However, understanding the general principle will inevitably help you interpret the results correctly.

Why Degrees of Freedom Matter in Statistics

Degrees of freedom exist because statistical calculations rely very heavily on estimates, like the sample mean or variance, which consume the information from the data. Therefore, without accounting for these constraints, our estimates of variability, confidence intervals, p-values, and others would be inaccurate.

Generally speaking, higher degrees of freedom predominantly lead to more precise estimates and narrower confidence intervals. They also appear in hypothesis testing because they determine which distribution to use and how much information the test has. Thereby, this directly affects the reliability of the statistical inference.

Degrees of Freedom Explained with a Simple Example

Suppose you have three friends who are splitting a restaurant bill of $60. You want the average payment to be $20 per person, so you follow  the next steps:

  1. You freely choose the first payment of $15.
  2. You freely choose the second payment of $25.
  3. The third payment must be $20 to make the average $20, which leads to a total of $60.

Person

Participation ($)

First Person

15

Second Person

25

Third Person

20

Mean

20

So even though you have three values, only two were free to vary. We say the last one was determined by the constraint (which is the fixed mean). Therefore, the degrees of freedom here are equal to 3-1=2.

This shows that the number of data points (3) is not the same as the degrees of freedom (2). We say the constraint uses up one degree of freedom.

Illustration of the degrees of freedom

Degrees of Freedom in Common Statistical Tests

In this section, I will show some examples of degrees of freedom in common statistical tests and how to use them.

Degrees of freedom in a t-test

For a one-sample t-test, degrees of freedom = n - 1. In this case, one degree of freedom is used up because we estimate the sample mean from the data. For a larger sample size, we are led to higher df with more reliable t-tests.

Degrees of freedom in chi-square tests

In a chi-square goodness-of-fit test, the degrees of freedom = number of categories - 1. Thus, the constraint is that the total observed frequency must equal the total expected frequency.

Degrees of freedom in ANOVA

In one-way ANOVA, the degrees of freedom are split between-groups (k-1, where k is the number of groups) and within-groups  (N-k, where N=total sample size). This shows the constraints from both group means and the overall mean of the dataset.

Common Misconceptions About Degrees of Freedom

In this section, I will address some of the most misconceived ideas about degrees of freedom. First and foremost, the degrees of freedom are not the sample size because the degrees of freedom are usually smaller due to the constraints that reduce them. 

In other words, degrees of freedom are not the same as the number of variables or parameters. They specifically count the independent pieces of information after the constraints.

Additionally, higher degrees of freedom are not always better, and there’s always a tradeoff because very large degrees of freedom can indicate overfitting or unrealistic assumptions in some contexts.

Degrees of Freedom vs. Sample Size

The sample size n is the total number of observations. While the degrees of freedom are not exactly the sample size, they are heavily influenced by it. This originates from the fact that degrees of freedom are typically n minus the number of constraints or estimated parameters. This is the reason why df is almost always smaller than n. The relationship between them exists because estimating the parameters imposes constraints on the data.

How to Interpret Degrees of Freedom

The rule of thumb is to focus less on the exact calculation and more on what the constraint actually represents.

Low degrees of freedom mean fewer independent pieces of information, which in turn leads to wider confidence intervals and less statistical power. You should trust your software’s output, but always make sanity checks, like asking the question of whether or not the reported degrees of freedom make sense given your sample size and the test being performed.

Conclusion

The degrees of freedom measure how much truly independent information is available in your data after accounting for all the constraints. The main idea to keep in mind is simple: every time you estimate a parameter or impose a restriction, you lose one degree of freedom. Therefore, understanding this concept strengthens your statistical intuition and helps you interpret test results with greater confidence. With practice, degrees of freedom will feel much less mysterious and far more meaningful.

Learn R for Machine Learning

Master core R skills to become a machine learning scientist
Start Learning for Free

Iheb Gafsi's photo
Author
Iheb Gafsi
LinkedIn

I work on accelerated AI systems enabling edge intelligence with federated ML pipelines on decentralized data and distributed workloads.  Mywork focuses on Large Models, Speech Processing, Computer Vision, Reinforcement Learning, and advanced ML Topologies.

FAQs

What are degrees of freedom in statistics?

Degrees of freedom (df) represent the number of values in a dataset that are free to vary after applying constraints, such as fixing the mean.

Why is degrees of freedom usually n-1?

One degree of freedom is "used up" when estimating the sample mean from the data, leaving n-1 independent values.

What is an example of degrees of freedom?

If three numbers must average 20, you freely choose two, but the third is fixed — so df = 3 − 1 = 2.

How do degrees of freedom differ in t-test vs chi-square?

In a one-sample t-test, df = n − 1. In chi-square goodness-of-fit, df = number of categories − 1.

Are degrees of freedom the same as sample size?

No. Degrees of freedom are usually smaller than sample size because constraints (like estimating the mean) reduce the number of free values.

Topics

Learn with DataCamp

Course

Statistical Thinking in Python (Part 1)

3 hr
185.6K
Build the foundation you need to think statistically and to speak the language of your data.
See DetailsRight Arrow
Start Course
See MoreRight Arrow
Related

blog

What is Data Science? Definition, Examples, Tools & More

Data science is an interdisciplinary field that uses scientific methods, processes, algorithms, and systems to extract knowledge and insights from structured and unstructured data.
Matt Crabtree's photo

Matt Crabtree

15 min

Tutorial

Sample Standard Deviation: The Key Ideas

Learn how to calculate sample standard deviation and understand its significance in statistical analysis. Explore examples and best practices for real-world data interpretation.
Allan Ouko's photo

Allan Ouko

Tutorial

Fisher’s Exact Test: Making Decisions with Small Samples

Learn to analyze categorical relationships when your sample sizes are small.
Vidhi Chugh's photo

Vidhi Chugh

Tutorial

Z-Score: The Complete Guide to Statistical Standardization

Learn the mathematical foundations of z-scores, explore practical calculation methods, and discover applications across statistics and data science.
Vinod Chugani's photo

Vinod Chugani

Tutorial

Joint Probability: Theory, Examples, and Data Science Applications

Learn how to calculate and interpret the likelihood of multiple events occurring simultaneously. Discover practical applications in predictive modeling, risk assessment, and machine learning that solve complex data science challenges.
Vinod Chugani's photo

Vinod Chugani

Tutorial

Binomial Distribution: A Complete Guide with Examples

Learn how the binomial distribution models multiple binary outcomes and is used in fields like finance, healthcare, and machine learning.
Vinod Chugani's photo

Vinod Chugani

See MoreSee More