DEV Community

Njeri Kimaru
Njeri Kimaru

Posted on

Degrees of Freedom and their role in Statistics

You’ve seen it in t-tests, chi-square, and regression: Degrees of Freedom (DoF). But what does it really mean?

🎓 A Simple Definition

Degrees of Freedom refers to the number of independent values in a calculation that are free to vary.

Imagine you have 3 numbers that must add up to 100. If you choose two freely, the third is fixed. So you have 2 degrees of freedom.

🧮 Why Do They Matter?

In statistics, DoF adjust for the fact that we estimate parameters (like the mean) from our sample data.

Examples:

1. Sample Variance


python
import numpy as np

data = [4, 7, 9]
print(np.var(data))        # population variance (DoF = N)
print(np.var(data, ddof=1)) # sample variance (DoF = N-1)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)