Chapter 11 · OpenStax Ch 11
The Chi-Square Distribution
Testing whether counts fit a claim, and whether two variables are independent.
11.1 Goodness of fit
Someone claims a die is fair, or claims any set of probabilities for its faces. Roll it \(n\) times and compare what you observed in each category with what the claim expected, \(E = n p\). The mismatch is summed into one number,
\[\chi^2 = \sum \frac{(O - E)^2}{E},\]
which is zero for a perfect match and grows as the counts drift from the claim. Under a true claim, \(\chi^2\) follows the chi-square distribution with \(k - 1\) degrees of freedom, six faces giving five. The table shows each face's contribution, and a few faces usually carry most of it. Repeat the test with the fair claim and the pile of statistics fills the orange curve, with 5 % beyond the critical value. Change the claim and the pile slides right. Every expected count should be at least 5 for the curve to be trusted.
Reading: OpenStax Introductory Statistics, Sections 11.1, 11.2.
11.2 Test of independence
Survey people about two things, whether they exercise and how well they sleep, and sort them into a contingency table. If the two are independent, every row splits across the columns in the same proportions, and the count independence expects in each cell is
\[E = \frac{\text{row total} \times \text{column total}}{n}.\]
The same \(\chi^2\) sum over the six cells measures how far the table strays from that, now with \((r - 1)(c - 1) = 2\) degrees of freedom. With the association slider at zero the two stacked bars match and the statistic behaves like the orange curve. One survey in twenty rejects by chance. Slide the association up and the rows part company, \(\chi^2\) climbs, and the p-value falls. Independence is the null hypothesis here. Rejecting it says the two variables are related, though not which causes which.
Reading: OpenStax Introductory Statistics, Sections 11.3 to 11.5.