stats.chisquare() compares observed frequencies with expected frequencies and returns a chi-square statistic and p-value for testing distributional agreement. section 12.5.1
Interpret the test through its statistic, p-value, and assumptions:
- Compute each contribution as (Oi − Ei)² / Ei, then sum contributions to obtain the chi-square statistic. section 12.5.1
- Compare the p-value with a 5% threshold: reject the null hypothesis below 5%; otherwise, fail to reject it. section 12.5.1
- Use enough records for meaningful conclusions and define expected counts before testing. section 12.5.1
Testing Benford-distributed population counts
Compute expected leading-digit counts, then call stats.chisquare(bf_populations.Counts, bf_populations.Expected_Counts). The result is statistic 7.1925 and p-value 0.5160, so the data does not significantly contradict the Benford-distribution null hypothesis.
