The chi-square goodness-of-fit test checks whether observed frequencies agree with the frequencies expected from a theoretical distribution, using \(\chi^2 = \sum \frac{(O-E)^2}{E}\).
Hypotheses. \(H_0\): the data follow the assumed distribution (the fit is good). \(H_1\): they do not.
Steps
- Find expected frequencies \(E_i\) from the assumed distribution (uniform, binomial, Poisson, normal, or a given ratio).
- Compute \(\chi^2 = \sum \dfrac{(O_i - E_i)^2}{E_i}\).
- Degrees of freedom \(= k - 1 - m\), where \(k\) = number of classes and \(m\) = number of parameters estimated from the data (e.g. \(m = 1\) when the Poisson mean is estimated).
- If calculated \(\chi^2\) > table value at level \(\alpha\), reject \(H_0\); otherwise the fit is good.
Conditions: observations independent, total frequency reasonably large (at least 50), and each expected frequency at least 5 (merge classes otherwise).
Example. A die is thrown 60 times. Is it fair?
| Face | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| O | 8 | 12 | 9 | 11 | 6 | 14 |
| E | 10 | 10 | 10 | 10 | 10 | 10 |
| \((O-E)^2\) | 4 | 4 | 1 | 1 | 16 | 16 |
\[\chi^2 = \frac{4+4+1+1+16+16}{10} = 4.2\]
df \(= 6 - 1 = 5\); table value \(\chi^2_{0.05}(5) = 11.07\). Since \(4.2 < 11.07\), do not reject \(H_0\): the die can be taken as fair.
Uses: testing Mendel's genetic ratios (9:3:3:1), checking whether data fit a Poisson or normal model, and checking whether customer arrivals are uniform across days.