IB Maths AI HLHypothesis Testing (Chi-squared)Paper 1 & 2~8 min read
Chi-Squared Test for Independence
A χ2 test for independence checks whether two variables are related — say, favourite subject and favourite film genre. You build a contingency table of observed frequencies, let the GDC compute the expected frequencies (what you’d see if the variables were independent) and the χ2 statistic, then compare against a critical value or significance level. The two things to get right by hand are the hypotheses and the degrees of freedomν = (m−1)(n−1).
📘 What you need to know
Purpose: test whether two variables are independent (a.k.a. a χ² two-way test); it’s a type of goodness of fit test.
Contingency table: a two-way table of observed frequencies for each combination of the two variables.
Expected values: what you’d expect if independent — the GDC gives these once you enter the observed matrix.
All expected values must be > 5; if any is ≤ 5, combine the appropriate row or column and recompute.
Degrees of freedom: for an m × n table, ν = (m−1)(n−1).
Decision: χ² statistic > critical value → reject H0; or p-value < significance level → reject.
Conclusion: reject → the variables are associated; accept → they appear independent.
Setting up the test
The null hypothesis is always that the two variables are independent; the alternative is that they’re not. Name the real variables — never just “X” and “Y”.
Hypotheses & degrees of freedomH0: the variables are independent | H1: the variables are not independent
ν = (m − 1)(n − 1) for an m × n contingency table
χ² test & the formula are in the booklet ✓
🤔 Why ν = (m−1)(n−1)?
The degrees of freedom count how many expected values you’d actually need to work out before the rest follow from the row and column totals. In a 5 × 3 table, once you know the entries in 4 of the rows and 2 of the columns, the totals fix everything else — so ν = 4 × 2 = 8. The “minus one” on each side is the constraint imposed by each total.
🤔 Why must expected values be > 5?
The χ2 test is an approximation, and it only stays reliable when each expected frequency is reasonably large. If one is 5 or less, the approximation breaks down, so you combine that category with an adjacent one — choosing the combination that makes sense (e.g. merge age bands, not unrelated genres) — then recompute the degrees of freedom.
The five steps
Every test for independence follows the same routine. The GDC does the heavy lifting in Step 3.
🧭 Recipe — chi-squared test for independence
Hypotheses: H0 independent, H1 not independent — name the real variables.
Degrees of freedom: ν = (m−1)(n−1) from the table size.
Enter the observed matrix into the GDC’s 2-way test; read off the expected matrix, the χ2 statistic, and the p-value. If any expected value ≤ 5, combine rows/columns and redo Step 2.
Decide: χ² statistic vs critical value (or p-value vs significance level).
Conclude in context: associated (reject) or independent (accept), tentatively.
From observed table to conclusion
The GDC produces the expected matrix, statistic and p-value; you handle the hypotheses, ν, and conclusion.
Conclusion wording: rejecting H0 means “sufficient evidence the variables are not independent — they’re associated“. Accepting means “insufficient evidence they’re not independent — so they appear independent“. Always phrase it with the real variables.
Worked examples
These run through the Paris-school test (favourite subject vs favourite film genre, 500 students, 1% level, critical value 16.812).
WE 1
Stating the hypotheses
A school tests whether favourite film genre is related to favourite subject using a χ² test. State the null and alternative hypotheses.
independence test → hypotheses about independenceH₀: favourite subject is independent of favourite film genre.H₁: favourite subject is not independent of favourite film genre.name the real variables, not X and Y
WE 2
Degrees of freedom
The contingency table has 3 subject rows (Maths, Sports, Geography) and 4 genre columns (Comedy, Action, Romance, Thriller). Find the degrees of freedom.
Entering the 3 × 4 observed matrix into the GDC, calculate the χ² test statistic.
type the observed matrix into the 2-way testall expected values > 5 (no combining needed)χ² statistic = 12.817…χ²calc ≈ 12.8 (3sf)the GDC also returns the expected matrix and the p-value.
WE 4
The conclusion
The test is at the 1% level with critical value 16.812. State the conclusion, with a reason.
compare statistic with critical value12.8 < 16.812accept H₀χ² statistic < critical value, so insufficient evidence that favourite subject is not independent of favourite film genre — they appear independent.
WE 5
When an expected value is too small
A different 4 × 3 table returns an expected value of 4.2 in one cell. Explain what to do and how it affects the degrees of freedom.
expected value ≤ 5 → must combinemerge that row (or column) with an adjacent, sensible one, then re-enter the matrix.recompute ν on the smaller tablee.g. 4 × 3 → 3 × 3 gives ν = (3−1)(3−1) = 4combine, then redo νfewer rows/columns means fewer degrees of freedom.
💡 Top tips
H₀ is always “independent”; H₁ is “not independent” — with the real variable names.
ν = (m−1)(n−1) from the table dimensions, computed by hand.
Check expected values > 5 before trusting the result; combine if not, then redo ν.
Let the GDC produce the expected matrix, χ² statistic, and p-value from the observed matrix.
Two decision routes: statistic > CV → reject, or p < significance level → reject.
“Associated” vs “independent”: reject → associated; accept → independent.
⚠ Common mistakes
Wrong degrees of freedom — using m × n or mn−1 instead of (m−1)(n−1).
Not combining when an expected value is ≤ 5 (and forgetting to recompute ν afterwards).
Comparing the wrong way — reject when statistic > CV (and p < α), not the reverse.
Vague hypotheses — writing “X” and “Y” instead of the actual variables.
Definitive conclusions — “proves they’re related” instead of “sufficient evidence to suggest…”.
Confusing observed and expected — enter only the observed frequencies; the GDC makes the expected ones.
Next up — the Goodness of Fit Test. The χ² machinery stays the same, but instead of testing whether two variables are independent, you’ll test whether a single variable fits a claimed distribution — uniform, binomial, normal, or Poisson — with the degrees of freedom adjusting depending on how many parameters you had to estimate.
Need help with Hypothesis Testing?
Get 1-on-1 help from an IB examiner who knows exactly what Paper 1 & 2 are looking for.