IB Maths AI HL Hypothesis 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

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 freedom H0: 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

  1. Hypotheses: H0 independent, H1 not independent — name the real variables.
  2. Degrees of freedom: ν = (m−1)(n−1) from the table size.
  3. 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.
  4. Decide: χ² statistic vs critical value (or p-value vs significance level).
  5. Conclude in context: associated (reject) or independent (accept), tentatively.
From observed table to conclusion
Observed contingency table GDC: expected + χ² + p-value Compare to CV or sig. level Conclude in context if any expected ≤ 5 → combine rows/columns, redo ν
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 independence H₀: 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.

ν = (rows − 1)(columns − 1) = (3 − 1) × (4 − 1) = 2 × 3 ν = 6 a 3 × 4 table gives 6 degrees of freedom.
WE 3

The χ² test statistic

Entering the 3 × 4 observed matrix into the GDC, calculate the χ² test statistic.

type the observed matrix into the 2-way test all 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 value 12.8 < 16.812 accept 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 combine merge that row (or column) with an adjacent, sensible one, then re-enter the matrix. recompute ν on the smaller table e.g. 4 × 3 → 3 × 3 gives ν = (3−1)(3−1) = 4 combine, then redo ν fewer rows/columns means fewer degrees of freedom.

💡 Top tips

⚠ Common mistakes

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.

Book Free Session →