📋 Summary — What This Chapter Covers
- Goodness of fit — comparing observed data (O) to expected data (E) predicted by a model, and testing if the model is any good.
- The test statistic X² — a single number measuring how "off" your observed values are from expected.
- Degrees of freedom (ν) — how many values were actually "free to vary" once totals and estimated parameters are accounted for.
- Testing against standard distributions — discrete uniform, binomial, Poisson, geometric — each with its own way of finding expected frequencies and degrees of freedom.
- Contingency tables — a two-way version of the same idea, testing whether two variables are independent of each other.
- Throughout: the golden rule that every expected value must be ≥ 5, or you must combine categories.
1. Goodness of Fit
Observed vs Expected
Think of it like this: you have a theory about how something behaves (a "model"), and you have real data from actually doing the thing. Goodness of fit measures how well the real data matches your theory.
Classic example — you flip a coin 20 times assuming it's fair. Your model (theory) says you should expect 10 heads. In reality, you observe 13 heads. Is 13 "close enough" to 10 to still believe the coin is fair? That's exactly the question a chi-squared test answers.
We lay observed values (Oᵢ) and expected values (Eᵢ) out in a table, one column per possible outcome. A really important check: the observed total and expected total must always match —
Hypotheses
Every chi-squared goodness of fit test starts the same way:
H₀ (null): There is no difference between the observed and the expected distribution (the model IS a good fit).
H₁ (alternative): The observed distribution cannot be modelled by the expected distribution (the model is NOT a good fit).
All chi-squared tests are one-tailed — you're only ever asking "is X² too big?", never "too big or too small."
Calculating the Test Statistic
Step 1 — combine columns. Before you calculate anything, check every expected value. If any Eᵢ is less than 5, you must merge that column with a neighbouring one until the combined expected value is 5 or more. This matters because the chi-squared approximation breaks down with small expected frequencies.
| Score | 1 | 2 | 3 | 4 |
| Oᵢ | 15 | 6 | 4 | 1 |
| Eᵢ | 12 | 8 | 4 | 2 |
Columns 3 and 4 have expected values below 5, so combine them:
Step 2 — calculate X². There are two equivalent formulas — use whichever is faster for the numbers you have:
The bigger X² is, the more the observed data disagrees with the model.
Degrees of Freedom (ν)