liveBook · Manning

Degree of freedom

As explained in Statistics Every Programmer Needs

Degrees of freedom are the number of independently varying values contributing to a statistical calculation after constraints are accounted for.

Degrees of freedom count the values in a statistical test’s final calculation that remain free to vary after constraints are applied. In a chi-square test, they help determine the p-value and statistical significance. section 12.5.1

For a chi-square goodness-of-fit calculation organized by rows and categories, derive degrees of freedom from the row and category counts. With 9 leading-digit rows and 2 categories, the result is (9 − 1)(2 − 1) = 8. section 12.5.1

Leading digits in world population counts

A chi-square statistic of 7.1925 with 8 degrees of freedom produces a p-value of about 0.516 using scipy.stats.chisquare(). Because the p-value exceeds 5%, the data do not provide grounds to reject conformity with the expected distribution. section 12.5.1

How Statistics Every Programmer Needs covers it

How deep it goes
Defines degrees of freedom, gives a row-and-category calculation, and connects the result to p-values without deriving the underlying distribution.
Examples
Uses leading-digit counts from world population data, a chi-square statistic of 7.1925, and 8 degrees of freedom.
What it assumes
Assumes familiarity with chi-square statistics, observed and expected counts, and p-values.
What you can do after
Evaluate chi-square significance by deriving degrees of freedom and interpreting an exact or table-based p-value.
How it connects
Connects degrees of freedom to chi-square tests, p-values, contingency tables, and Benford distribution.

Also explained in

Compare how 3 books explain degree of freedom →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Every Programmer Needs. The section links point to the parts of the book it draws on.