IB Maths AI HLHypothesis Testing (Chi-squared)Paper 1 & 2~9 min read
Goodness of Fit Test
A χ2 goodness of fit test checks whether one variable follows a claimed distribution — uniform, a given ratio, binomial, Poisson or normal. You compare observed frequencies against the expected frequencies that distribution predicts. The machinery (GDC gives χ2 and p-value, then compare) is identical to the independence test — the only new skills are building the expected frequencies yourself and getting the degrees of freedom right, which now drop by an extra 1 for every parameter you had to estimate.
📘 What you need to know
Purpose: test whether one variable fits a given distribution (uniform, ratio, binomial, Poisson, normal).
Hypotheses: H0 “can be modelled by the distribution”; H1 “cannot” — name the real variable.
Expected frequencies: probability of each outcome × total N. You build these (unlike the independence test, where the GDC does).
All expected values > 5; if any is ≤ 5, combine with an adjacent class and recompute.
Degrees of freedom: ν = k − 1 − (number of parameters estimated), where k is the number of classes left.
Decision: χ² statistic > critical value → reject; or p-value < significance level → reject.
Conclusion: reject → data does not fit the distribution; accept → data appears to fit it.
Setting up the test
The null hypothesis is always that the variable can be modelled by the named distribution; the alternative is that it cannot. If you’re given the parameters, state the precise distribution.
Hypotheses & degrees of freedomH0: variable fits the distribution | H1: it does not
ν = k − 1 − p (k = classes after combining, p = parameters estimated)
χ² test & the formula are in the booklet ✓
🤔 Why does ν drop by 1 for each estimated parameter?
Each parameter you estimate from the sample (a value of p, m, μ or σ) is one more thing the data has been forced to match, so it removes a degree of freedom. Given the parameter → ν = k − 1. Estimate one → k − 2. Estimate both μ and σ for a normal → k − 3.
Distribution
Parameters estimated
Degrees of freedom
Uniform / given ratio
none
ν = k − 1
Binomial / Poisson (given)
none
ν = k − 1
Binomial / Poisson (estimated)
p or m
ν = k − 2
Normal (one estimated)
μ or σ
ν = k − 2
Normal (both estimated)
μ and σ
ν = k − 3
The six steps
The routine adds two jobs compared with the independence test: you build the expected frequencies, and you adjust ν for estimated parameters.
🧭 Recipe — chi-squared goodness of fit test
Hypotheses: H0 fits the distribution, H1 does not — name the real variable; state the precise distribution if given.
Expected frequencies: P(each outcome) × total N. Combine any class with expected ≤ 5.
Degrees of freedom: ν = k − 1 − (parameters estimated).
Enter observed & expected as two lists in the GDC; read off χ2 and the p-value.
Decide: χ² statistic vs critical value (or p-value vs significance level).
Conclude in context: fits (accept) or does not fit (reject), tentatively.
Independence test vs goodness of fit
Both tests share the same decision machinery — only how you get the expected values and ν differs.
Conclusion wording: rejecting H0 means “sufficient evidence the variable does not follow the distribution”. Accepting means “insufficient evidence against it — so it appears to follow the distribution”. Always name the real variable and stay tentative.
Worked examples
WE 1–2 use the car-salesman sales data (uniform). WE 3 uses the video-game bosses data (binomial). WE 4–5 use the marbled-ducks data (normal).
WE 1
Uniform — expected frequencies & ν
A salesman records sales over 6 weeks: 15, 17, 11, 21, 14, 12. A χ² test at the 5% level checks for a uniform distribution. Find the expected frequency per week and the degrees of freedom.
uniform → all expected frequencies equaltotal = 15+17+11+21+14+12 = 90expected each week = 90 ÷ 6 = 15.ν = k − 1 (no parameters estimated)= 6 − 1expected = 15, ν = 5
WE 2
Uniform — decision & conclusion
Entering observed (15, 17, 11, 21, 14, 12) and expected (all 15) into the GDC gives p = 0.493. State the conclusion at the 5% level, with a reason.
compare p with significance level0.493 > 0.05accept H₀p-value > significance level, so insufficient evidence that the number of sales is not uniform — it appears uniformly distributed.
WE 3
Binomial (given p) — expected value & ν
1000 players defeat 0, 1, 2 or 3 bosses (observed 490, 384, 111, 15). Test against B(3, 0.2) at 5%. Find the expected frequency for “1 boss” and the degrees of freedom.
expected = P(X = x) × N, with X ~ B(3, 0.2)P(X = 1) = 0.384 → 1000 × 0.384 = 384ν = k − 1 (p was given, not estimated)= 4 − 1expected(1) = 384, ν = 3expected values 512, 384, 96, 8 are all > 5, so no combining; GDC gives p ≈ 0.0243.
WE 4
Normal — why combine, and ν
300 ducks fall into classes m<450, 450≤m<470, 470≤m<520, 520≤m<570, m≥570 (freq 1, 9, 158, 123, 9). Tested against N(520, 30²). The first class has expected ≈ 2.94. Explain the fix and give ν.
expected ≤ 5 → must combinemerge m<450 with 450≤m<470 → one class m<470 (observed 10), giving k = 4 classes.ν = k − 1 (μ and σ both given, not estimated)= 4 − 1combine, ν = 3
WE 5
Normal — statistic & conclusion
For the ducks (4 combined classes), the GDC gives χ² = 8.16. The critical value at 10% is 6.251. State the conclusion, with a reason.
compare statistic with critical value8.16 > 6.251reject H₀χ² statistic > critical value, so sufficient evidence that the mass of a marbled duck cannot be modelled by N(520, 30²).
💡 Top tips
H₀ is always “fits the distribution”; H₁ is “does not” — with the real variable name.
State the precise distribution (e.g. B(3, 0.2), N(520, 30²), Po(m)) when the parameters are given.
Build expected = P(outcome) × N; on the end classes use P(X ≤ a) and P(X ≥ b) so the probabilities sum to 1.
Check expected > 5, combine sensible adjacent classes if not, then recount k.
Adjust ν last: k − 1, minus 1 more for each parameter you estimated.
For normal, estimating both μ and σ costs 2 → ν = k − 3.
⚠ Common mistakes
Forgetting the parameter penalty — using k − 1 when you estimated p, m, μ or σ.
Wrong ν after combining — counting k before merging the small class instead of after.
End classes not unbounded — using P(X = a) instead of P(X ≤ a) / P(X ≥ b), so probabilities don’t total 1.
Comparing the wrong way — reject when statistic > CV (and p < α), not the reverse.
Vague hypotheses — writing “X” instead of the real variable, or omitting the distribution.
Definitive conclusions — “proves it’s normal” instead of “insufficient evidence to suggest it isn’t”.
That wraps the Hypothesis Testing using the Chi-squared Distribution unit — you’ve now met the language of testing, the test for independence, and goodness of fit across uniform, binomial, Poisson and normal models. The thread tying it together: build (or read off) expected frequencies, keep every expected value above 5, get ν right, then let the GDC and one comparison decide. Next unit, you’ll carry this same hypothesis-testing logic into tests built on the normal distribution and comparing means.
Need help with Hypothesis Testing?
Get 1-on-1 help from an IB examiner who knows exactly what Paper 1 & 2 are looking for.