Chi-squared tests and the t-test
In a minute
A hypothesis test asks whether data give real evidence for a claim or could be chance. You set up hypotheses, use and , and run three GDC tests: χ² for independence, χ² goodness of fit and the for two means.
You'll be able to
- Write and in words, as an equation or as an inequality.
- Decide with a significance level and a p-value, and conclude in context.
- Find expected frequencies from a or a claimed distribution.
- Run χ² tests for independence and goodness of fit, with , a or a p-value.
- Run a pooled t-test for two means, one-tailed or two-tailed, and interpret it.
Before you start3 quick questions on what this builds on
Revise first: 4.1 Sampling, data quality and outliers, 4.4 Correlation and regression (y on x), 4.5 Probability foundations and expected value and 4.6 Probability diagrams, rules and independence
Hypotheses, significance levels and p-values
A difference in a small could be luck. A hypothesis test asks whether data are too unusual for luck. It starts with two statements about the , not the sample.
Write them in words, as an equation or as an inequality. For population means, : , and is , or .
For two categorical variables, : they are independent; : they are not independent. Mark schemes refuse "not correlated" and "not related".
Try it first, then reveal one step at a time.
- (a) District and travel method are categorical, so the hypotheses are about independence.
- (b) This compares two population means. The coach expects an increase, so has a direction: .
- (a) : travel method is independent of district; : travel method is not independent of district. (b) : ; : (population mean is greater with the new warm-up).
Not rejecting does not prove it: there is just not enough evidence against it. And a p-value is not the probability that is true.
Try it first, then reveal one step at a time.
- (a) Compare the p-value with . It is smaller, so reject .
- (b) Compare the p-value with . It is bigger, so do not reject .
- The conclusions differ because demands stronger evidence. That is why the level is fixed before the test.
- (a) : reject ; the step goal is not independent of phone brand. (b) : do not reject ; insufficient evidence of dependence.
Observed and expected frequencies
A χ² (chi-squared) test compares the counts you recorded with the counts predicts.
It works like the : when gives the probabilities, multiply each by the total count.
In a contingency table, says the variables are independent, so , as for . Multiplying by the grand total gives:
Try it first, then reveal one step at a time.
- Row total for South: . Column total for bike: . Grand total: .
- .
- Interpret: southerners cycle against expected. A test decides whether that gap is too big to be chance.
Try it first, then reveal one step at a time.
- Multiply each claimed probability by . Red: . Yellow: .
- White: . Purple: .
- Check: , the observed total.
The χ² test for independence
The test statistic adds up the gaps between observed and expected counts, each squared and scaled. Small gaps fit ; big gaps are evidence against it.
In exams your GDC calculates it. The test also needs its : how many cells can vary once the totals are fixed. For rows and columns:
Only a large counts against , so χ² tests use the upper tail only. Compare with the given, or the p-value with the significance level.
In exam questions, tables have at most rows or columns, df is more than , and every expected frequency is greater than . With expected frequencies of or less the test is unreliable: remember this in your exploration.
Try it first, then reveal one step at a time.
- : travel method is independent of region. : travel method is not independent of region.
- Expected frequencies: North , , ; South , , . All are greater than .
- .
- Contributions : North , , ; South , , .
- Add them: .
- Compare: , so reject . There is evidence at the level that travel method is not independent of region.
- The biggest contributions are in the car and bike columns: southerners cycle more, and drive less, than independence predicts.
Try it first, then reveal one step at a time.
- : favourite genre is independent of age group. : favourite genre is not independent of age group.
- Enter the observed counts as a matrix and run the χ² 2-way test.
- Read off , and p-value . The smallest expected value is , so all are greater than .
- Compare: , so reject .
- There is evidence at the level that favourite genre is not independent of age group. Older subscribers chose documentaries more often than expected.
The χ² goodness of fit test
Sometimes one variable comes with a claim about how its counts split: equally, or in stated proportions.
The statistic is the same, with expected frequencies from the claimed probabilities. At SL, with categories:
One is lost because the expected total must equal the observed total. On the GDC, enter observed and expected counts as lists and type the df.
Try it first, then reveal one step at a time.
- : returns are equally likely on each weekday (a uniform distribution). : returns are not equally likely on each weekday.
- Expected: each, all greater than . .
- GDC with observed and expected each: , p-value .
- Compare: , so do not reject .
- There is insufficient evidence at the level that returns are more likely on some weekdays.
Try it first, then reveal one step at a time.
- : the colours follow the claimed proportions. : the colours do not follow the claimed proportions.
- Expected frequencies (found earlier): , all greater than . .
- GDC with observed and expected : .
- Compare: , so reject .
- There is evidence at the level that the mix does not grow the claimed proportions: fewer red and more yellow flowers than claimed.
The t-test for two means
For measurements, compare two means.
Conditions: both variables are normally distributed; the samples are unpaired (different individuals, chosen independently); the population variances are unknown but assumed equal, so the GDC pools them.
The samples can differ in size. Always use technology: enter both samples as lists and read the p-value.
Try it first, then reveal one step at a time.
- : ; : , for the population mean heights. "Differ" with no direction means two-tailed.
- Pooled two-sample t-test: lamp in list 1, lamp in list 2, , Pooled: Yes.
- The GDC gives , and p-value .
- Compare: , so reject .
- There is evidence at the level that mean seedling height differs between the lamps. The sample means suggest lamp grows taller seedlings.
Try it first, then reveal one step at a time.
- : ; : , for the population mean reaction times without and with a phone. "Lower" gives a direction, so one-tailed.
- The groups are different drivers, so the samples are unpaired. No-phone data in list 1, phone data in list 2, , Pooled: Yes.
- The GDC gives , and p-value .
- Compare: , so reject .
- There is evidence at the level that mean reaction time is lower without a phone. The test shows the difference is unlikely to be chance, not how big it is.
Common mistakes
- Writing "not correlated" or "not related" in χ² hypotheses. Use "independent" and "not independent".
- Concluding with no comparison. Write the numbers, such as , before the decision.
- Leaving out the context, or saying the test proves . Say what it means for the variables.
- Writing hypotheses with sample means . They are about population means .
- Rounding the p-value too far, such as for . Give 3 s.f.
- Setting Pooled to No, or choosing the wrong tail for on the GDC.
Exam tips
- State the hypotheses: name the variables and say "independent", "follow the claimed distribution" or "population mean".
- Find the p-value: write the test you ran and the data you entered, then the p-value to 3 s.f.
- Write down the degrees of freedom: for a contingency table, for goodness of fit at SL.
- State the conclusion, justify it: comparison, decision, meaning in context. A decision with no reason scores nothing.
Key takeaways
Practise this
22 past-paper questions on Chi-squared tests in the AI HL bank, each with a mark scheme and a worked explanation.
Also: The t-test (16)