χ² tests: independence & goodness of fit
Hypothesis testing with the χ² statistic. The test for independence asks whether two categorical variables are linked; the goodness of fit test asks whether data matches a claimed distribution. You write the hypotheses, the GDC finds χ² and the p-value, and you write the conclusion in context.
1What you need to know
Tick these off as you go. By the end of the page you should be able to do all of them without notes.
- Write null and alternative hypotheses, and , in wordsSL 4.11
- Find expected frequencies for a contingency tableSL 4.11
- Find the degrees of freedom for a test for independence and for a goodness of fit testSL 4.11
- Use the GDC to find the χ² statistic and the p-valueSL 4.11
- Reach a conclusion by comparing the p-value with the significance level, or χ² with the critical valueSL 4.11
- Write the conclusion in contextSL 4.11
2Notes & worked examples
Each idea is followed by a worked example. Try the question yourself first, then reveal the solution one step at a time.
A χ² test measures how far the observed frequencies are from the frequencies you would expect if the null hypothesis were true. Small differences could be chance; big differences give a large χ² and a small p-value, which is evidence against . The p-value is the probability of getting data this extreme if were true: if it is smaller than the significance level, reject .
2.1 The structure of every test
- Hypotheses. : the "nothing interesting" statement (the variables are independent; the data fits the distribution). : the opposite.
- Degrees of freedom .
- GDC: χ² statistic and p-value.
- Decision: if p-value significance level (or χ² critical value), reject ; otherwise do not reject .
- Conclusion in context.
2.2 The χ² test for independence
Use the table of observed values only, not the totals, to count rows and columns.
| Football | Tennis | Swimming | Total | |
|---|---|---|---|---|
| Year 11 | 30 | 25 | 15 | 70 |
| Year 12 | 20 | 35 | 25 | 80 |
| Total | 50 | 60 | 40 | 150 |
Alternatively, compare χ² with a critical value given in the question (here 5.991 for at 5%): , so do not reject .
2.3 The χ² goodness of fit test
Here says the data follows a stated distribution (uniform, or given percentages). Expected frequencies come from that distribution. At AI SL, , where is the number of categories.
Independence: make a matrix of the observed values (templates key → matrix, choose rows and columns), store it as obs. Then menu → Statistics → Stat Tests → χ² 2-way Test and enter obs. The output gives χ², the p-value and df; the expected values are stored in stat.ExpMatrix. Goodness of fit: put observed values in one list and expected values in another, then menu → Statistics → Stat Tests → χ² GOF, with the degrees of freedom.
3Explore it
The curve is the χ² distribution for your degrees of freedom. Move the test statistic: the shaded tail is the p-value. Compare it with the significance level, and see where the critical value lies.
4Common mistakes & exam tips
Common mistakes
- Writing the hypotheses the wrong way round: is always "independent" or "fits the distribution".
- Counting the totals row and column when finding the degrees of freedom.
- Saying "accept ". Say "do not reject " or "there is insufficient evidence to reject ".
- Rejecting when the p-value is larger than the significance level.
- Giving a conclusion with no context.
Exam tips
- The expected frequency formula is not in the booklet as words, but "row total × column total ÷ grand total" is quick to remember.
- Use either the p-value or the critical value, as the question asks; you never need both.
- A full conclusion has three parts: the comparison, the decision about , and what it means in context.
- Expected frequencies in IB questions are always above 5.
5Practice
Fluency questions build the basics. Problem-solving questions make you think about which method to use.
6Exam-style questions
Original questions in the style of the IB Maths AI SL exam, with full markschemes. Your GDC is allowed throughout: use it, but write down what you entered and what it gave you. Give yourself about 1 minute per mark.
170 people were asked whether they prefer streaming or cinema, by age group.
| Streaming | Cinema | |
|---|---|---|
| Under 25 | 45 | 15 |
| 25 to 50 | 35 | 25 |
| Over 50 | 20 | 30 |
- (a)Write down the null and alternative hypotheses.[1]
- (b)Show that the expected frequency for "Under 25, Streaming" is 35.3, to 3 s.f.[2]
- (c)Write down the number of degrees of freedom.[1]
- (d)Find the χ² statistic and the p-value.[2]
- (e)State the conclusion of the test, giving a reason.[2]
| (a) | |
| : preference is independent of age group; : it is not independent | A1 |
| (b) | |
| M1 | |
| AG A1 | |
| (c) | |
| 2 | A1 |
| (d) | |
| A1 | |
| p-value | A1 |
| (e) | |
| R1 | |
| reject : preference depends on age group | A1 |
The number of cars of each colour passing a junction is recorded: white 48, black 35, grey 27, red 40. A goodness of fit test is used to test whether the four colours are equally common, at the 10% level.
- (a)Write down the null hypothesis.[1]
- (b)Write down the expected frequency for each colour.[1]
- (c)Find the p-value.[2]
- (d)State the conclusion of the test.[2]
| (a) | |
| the four colours are equally common | A1 |
| (b) | |
| 37.5 | A1 |
| (c) | |
| (A1) | |
| 0.102 | A1 |
| (d) | |
| R1 | |
| do not reject : no evidence that the colours are not equally common | A1 |
A survey of 120 people recorded their favourite type of film (comedy, action, drama) and whether they were under 30. A χ² test for independence at the 1% level gave . The critical value is 9.210.
- (a)Write down the number of degrees of freedom.[1]
- (b)State the conclusion of the test, giving a reason.[2]
- (c)The test is repeated at the 5% level, with critical value 5.991. State the new conclusion.[2]
- (d)Explain why the two conclusions differ.[1]
| (a) | |
| A1 | |
| (b) | |
| R1 | |
| do not reject : no evidence that film type depends on age | A1 |
| (c) | |
| R1 | |
| reject : film type depends on age | A1 |
| (d) | |
| a 5% test needs less evidence to reject than a 1% test | R1 |
7Check yourself
Six quick questions, marked instantly. Aim for 6/6 before moving on. Fractions like 3/2 are accepted.
8Past-paper practice
Once you're scoring well above, try these real IB Maths AI SL questions. Your school or teacher will have the papers.
| Paper | Question | Focus | Difficulty |
|---|---|---|---|
| May 2025 · TZ2 · Paper 1 | Q4 | Pet food vs animal: χ² independence at two significance levels | ★★★ |
| May 2026 · TZ2 · Paper 2 | Q2 | Scratchcards: fair game, then χ² goodness of fit | ★★★ |
| May 2026 · TZ1 · Paper 1 | Q10 | Spinner fairness: χ² goodness of fit, p-value | ★★☆ |
| May 2025 · TZ1 · Paper 1 | Q2 | Car colour vs age group: expected value, χ², conclusion | ★☆☆ |
