Goodness of Fit
To check whether counts fit a claimed distribution, work out the counts the claim predicts and measure how far off you landed. The chi-square statistic adds up each squared miss relative to what was expected, so it's near zero for a good fit and big for a bad one.
What the symbols mean
- Chi-square statistic
Zero for a perfect fit; large values mean the counts disagree with the claim.
- Observed count
What actually happened in each category.
- Expected count
What the claimed distribution predicts: n times the category's probability.
- Number of categories
Degrees of freedom are one less.
Explanation
A goodness-of-fit test is simply a check of whether counts in several categories match what some claim predicts, like whether a die's 60 rolls fit a fair die. The name says it: how good is the fit between the claim and the data? It's what you reach for when there's no single mean or proportion to test, just a row of counts. The formula looks intimidating, but it's just three small moves repeated for each category: (how far off the count was), squaring it (so misses up and down both count), and dividing by (judging the miss against what you expected). Then the adds up all the categories. That's the whole thing; it looks worse than it is.
Why divide by ? A miss of 5 means a lot when you expected 10, and very little when you expected 1000. Dividing each squared miss by puts every category on the same footing. Squaring does the other job: misses above and below expected can't cancel out, so every disagreement adds to .
Procedure:
- : the claimed distribution is correct. : it isn't.
- Expected counts: for each category.
- Compute and compare with the critical value for , or find the p-value. The test is always right-tailed: only big disagreements count against .
The degrees of freedom are rather than because the counts have to add up to . Once you know of them, the last one is forced.
Condition: every expected count should be at least 5.
The chi-square distribution is skewed right and depends on its degrees of freedom; its mean is . That gives you a quick sense of scale: with degrees of freedom, a around is completely ordinary.
A common mistake. When you fail to reject, it's tempting to say the claim has been confirmed. It hasn't. A small only means your data don't contradict the claim. A different sample, or a bigger one, might.
See it
Worked examples
A die is rolled 60 times, giving counts for faces 1 to 6. Is it fair? (, critical value for .)
- 1
A fair die lands on each face with probability , so the expected count is per face.
Practice
Type your answer and check it. Solve them all to complete the lesson.
For the 60 die rolls, what is the expected count for each face?
Compute for the counts .
How many degrees of freedom does the test have?
With critical value 11.07, what is the decision?
A shop expects equal sales Monday to Friday and sees . Compute .
A candy maker says its bags are 30% red, 20% blue and 50% green. A bag of 100 has 22 red, 28 blue and 50 green. Compute .
For that bag, there are degrees of freedom and the critical value at is 5.991. What's the decision?
The hardest one here. Get it, and you've got this lesson.
Benford's law says the leading digit of many real-world numbers appears with probability . Find the probability of a leading 1, and the number of 500 honest invoices expected to start with 1 or 2. Enter both.
Where it's used
Geneticists test whether offspring match Mendel's ratios, casinos audit dice and cards, and auditors use goodness of fit (Benford's law) to spot fabricated numbers.