4.11 · SLPaper 1Paper 2

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 H0\mathrm{H}_0 and H1\mathrm{H}_1 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
Check yourself
AA and BB are independent, P(A)=0.3\mathrm{P}(A) = 0.3 and P(B)=0.6\mathrm{P}(B) = 0.6. Find P(A∩B)\mathrm{P}(A \cap B).
Check yourself
P(a bottle is underfilled)=0.04\mathrm{P}(\text{a bottle is underfilled}) = 0.04. How many of 350350 bottles do you expect to be underfilled?
Check yourself
For 1010 pairs of data, r=0.583r = 0.583. The critical value of rr at the 5%5\% level is 0.6320.632. What can you conclude?

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, H0\mathrm{H}_0: μ1=μ2\mu_1 = \mu_2, and H1\mathrm{H}_1 is μ1≠μ2\mu_1 \neq \mu_2, μ1>μ2\mu_1 > \mu_2 or μ1<μ2\mu_1 < \mu_2.

For two categorical variables, H0\mathrm{H}_0: they are independent; H1\mathrm{H}_1: they are not independent. Mark schemes refuse "not correlated" and "not related".

Worked exampleWrite down H0\mathrm{H}_0 and H1\mathrm{H}_1. (a) A council asks whether the way people travel to work depends on their district. (b) A coach thinks a new warm-up raises her athletes' mean jump height, μnew\mu_{\text{new}}, above the old mean, μold\mu_{\text{old}}.

Try it first, then reveal one step at a time.

  1. (a) District and travel method are categorical, so the hypotheses are about independence.
Check yourself
A health visitor thinks teenagers in town A sleep less, on average, than teenagers in town B. Which is the correct H1\mathrm{H}_1?

Not rejecting H0\mathrm{H}_0 does not prove it: there is just not enough evidence against it. And a p-value is not the probability that H0\mathrm{H}_0 is true.

Worked exampleA fitness app tests whether hitting a weekly step goal is independent of phone brand. The p-value is 0.03720.0372. State the conclusion at the (a) 5%5\%, (b) 1%1\% significance level.

Try it first, then reveal one step at a time.

  1. (a) Compare the p-value with 0.050.05. It is smaller, so reject H0\mathrm{H}_0.
Check yourself
A test gives a p-value of 0.0630.063. At which of the usual significance levels do you reject H0\mathrm{H}_0?

Observed and expected frequencies

A χ² (chi-squared) test compares the counts you recorded with the counts H0\mathrm{H}_0 predicts.

It works like the : when H0\mathrm{H}_0 gives the probabilities, multiply each by the total count.

In a contingency table, H0\mathrm{H}_0 says the variables are independent, so P(row and column)=P(row)×P(column)\mathrm{P}(\text{row and column}) = \mathrm{P}(\text{row}) \times \mathrm{P}(\text{column}), as for . Multiplying by the grand total gives:

Learn this
fe=row total×column totalgrand totalf_e = \frac{\text{row total} \times \text{column total}}{\text{grand total}}
Worked exampleA survey of 200200 commuters records region and travel method. North: car 3030, bus 2323, bike 2727. South: car 2020, bus 3737, bike 6363. If region and travel method are independent, how many southern commuters would you expect to cycle?

Try it first, then reveal one step at a time.

  1. Row total for South: 20+37+63=12020 + 37 + 63 = 120. Column total for bike: 27+63=9027 + 63 = 90. Grand total: 200200.
Worked exampleA seed company claims its wildflower mix grows 40%40\% red, 25%25\% yellow, 20%20\% white and 15%15\% purple flowers. A gardener grows 220220 plants from the mix. Find the expected frequency of each colour if the claim is true.

Try it first, then reveal one step at a time.

  1. Multiply each claimed probability by 220220. Red: 220×0.40=88220 \times 0.40 = 88. Yellow: 220×0.25=55220 \times 0.25 = 55.
Check yourself
A cinema thinks its 44 screens are equally popular. It sells 236236 tickets one evening. Find the expected number for each screen under H0\mathrm{H}_0.

The χ² test for independence

The test statistic adds up the gaps between observed and expected counts, each squared and scaled. Small gaps fit H0\mathrm{H}_0; big gaps are evidence against it.

Learn this
χcalc2=∑(fo−fe)2fe\chi^2_{\text{calc}} = \sum \frac{(f_o - f_e)^2}{f_e}

In exams your GDC calculates it. The test also needs its : how many cells can vary once the totals are fixed. For rr rows and cc columns:

Learn this
df=(r−1)(c−1)\text{df} = (r - 1)(c - 1)

Only a large χcalc2\chi^2_{\text{calc}} counts against H0\mathrm{H}_0, so χ² tests use the upper tail only. Compare χcalc2\chi^2_{\text{calc}} with the given, or the p-value with the significance level.

Right-skewed chi-squared curve. A vertical line marks the critical value. The small area under the curve to the right of it is shaded: this upper tail is the reject region, and its area is the significance level. Values to the left of the critical value mean do not reject the null hypothesis. critical value small χ²: do not reject H₀ large χ²: reject H₀ shaded area = significance level
Reject H0\mathrm{H}_0 when χcalc2\chi^2_{\text{calc}} is greater than the critical value.

In exam questions, tables have at most 44 rows or columns, df is more than 11, and every expected frequency is greater than 55. With expected frequencies of 55 or less the test is unreliable: remember this in your exploration.

Worked exampleUse the commuter survey (North: car 3030, bus 2323, bike 2727; South: car 2020, bus 3737, bike 6363) to test whether travel method is independent of region, at the 5%5\% level. Use the critical value 5.9915.991.

Try it first, then reveal one step at a time.

  1. H0\mathrm{H}_0: travel method is independent of region. H1\mathrm{H}_1: travel method is not independent of region.
Worked exampleA streaming service records the age group and favourite genre of 371371 subscribers. Under 25: drama 4444, comedy 2929, documentary 2424. Aged 25 to 44: drama 3838, comedy 4141, documentary 3636. Aged 45 and over: drama 3333, comedy 4949, documentary 7777. Use your calculator to find the p-value of a χ² test for independence, to 3 s.f., and conclude at the 1%1\% level.

Try it first, then reveal one step at a time.

  1. H0\mathrm{H}_0: favourite genre is independent of age group. H1\mathrm{H}_1: favourite genre is not independent of age group.
Check yourself
A contingency table has 33 rows and 44 columns. Write down the degrees of freedom for a χ² test for independence.
Check yourself
A school tests at the 5%5\% level whether lunch choice is independent of year group. χcalc2=4.12\chi^2_{\text{calc}} = 4.12 and the critical value is 7.8157.815. Which conclusion is correct?

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 nn categories:

Learn this
df=n−1\text{df} = n - 1

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.

Worked exampleA library records the weekday of 150150 book returns: Monday 3838, Tuesday 2727, Wednesday 3030, Thursday 2222, Friday 3333. Test at the 10%10\% level whether returns are equally likely on each weekday. Use your calculator and give the p-value to 3 s.f.

Try it first, then reveal one step at a time.

  1. H0\mathrm{H}_0: returns are equally likely on each weekday (a uniform distribution). H1\mathrm{H}_1: returns are not equally likely on each weekday.
Worked exampleThe gardener's 220220 plants were red 7070, yellow 7070, white 4848 and purple 3232. The company claims 40%40\%, 25%25\%, 20%20\% and 15%15\%. Test the claim at the 5%5\% level, using the critical value 7.8157.815.

Try it first, then reveal one step at a time.

  1. H0\mathrm{H}_0: the colours follow the claimed proportions. H1\mathrm{H}_1: the colours do not follow the claimed proportions.
Check yourself
A goodness of fit test checks whether a six-sided dice is fair. Write down the degrees of freedom.
Check yourself
A bakery claims its four bread types sell equally well. A goodness of fit test at the 10%10\% level gives a p-value of 0.04180.0418. Which conclusion is correct?

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.

Two bell-shaped t-distribution curves side by side. Left, two-tailed test with H1 mu1 not equal to mu2: the areas beyond minus t and beyond t are both shaded, and the p-value is the total of both tails. Right, one-tailed test with H1 mu1 greater than mu2: only the area beyond t on the right is shaded, and the p-value is that one tail. Two-tailed H₁: μ₁ ≠ μ₂ t −t p = both shaded tails One-tailed H₁: μ₁ > μ₂ t p = one shaded tail
Two-tailed: the p-value counts both tails. One-tailed: only the tail H1\mathrm{H}_1 points to.
Worked exampleSeedling heights, in cm, under two lamps. Lamp AA: 41.2,38.5,44.0,39.8,42.6,40.1,43.3,37.941.2, 38.5, 44.0, 39.8, 42.6, 40.1, 43.3, 37.9. Lamp BB: 36.4,39.0,35.2,38.1,34.7,37.5,36.936.4, 39.0, 35.2, 38.1, 34.7, 37.5, 36.9. Assume normal distributions with equal variances. Test at the 5%5\% level whether the mean heights differ. Use your calculator and give the p-value to 3 s.f.

Try it first, then reveal one step at a time.

  1. H0\mathrm{H}_0: μA=μB\mu_A = \mu_B; H1\mathrm{H}_1: μA≠μB\mu_A \neq \mu_B, for the population mean heights. "Differ" with no direction means two-tailed.
Worked exampleSimulator reaction times, in seconds. Drivers without a phone: 0.312,0.298,0.285,0.301,0.276,0.290,0.305,0.281,0.2940.312, 0.298, 0.285, 0.301, 0.276, 0.290, 0.305, 0.281, 0.294. Other drivers on a hands-free phone: 0.305,0.318,0.296,0.322,0.309,0.299,0.314,0.3110.305, 0.318, 0.296, 0.322, 0.309, 0.299, 0.314, 0.311. Assume normal distributions with equal variances. Test at the 1%1\% level whether mean reaction time is lower without a phone. Give the p-value to 3 s.f.

Try it first, then reveal one step at a time.

  1. H0\mathrm{H}_0: μN=μP\mu_N = \mu_P; H1\mathrm{H}_1: μN<μP\mu_N < \mu_P, for the population mean reaction times without and with a phone. "Lower" gives a direction, so one-tailed.
Check yourself
Which of these is not a condition for the pooled two-sample t-test at SL?
Check yourself
A two-tailed t-test gives a p-value of 0.0740.074. The sample means differ in the direction a one-tailed H1\mathrm{H}_1 predicts. Find the one-tailed p-value for the same data.

Common mistakes

  • Writing "not correlated" or "not related" in χ² hypotheses. Use "independent" and "not independent".
  • Concluding with no comparison. Write the numbers, such as 0.0372<0.050.0372 < 0.05, before the decision.
  • Leaving out the context, or saying the test proves H0\mathrm{H}_0. Say what it means for the variables.
  • Writing hypotheses with sample means xˉ\bar{x}. They are about population means μ\mu.
  • Rounding the p-value too far, such as 0.030.03 for 0.0297…0.0297\ldots. Give 3 s.f.
  • Setting Pooled to No, or choosing the wrong tail for μ1\mu_1 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: (r−1)(c−1)(r - 1)(c - 1) for a contingency table, n−1n - 1 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

Learn thisfe=row total×column totalgrand totalf_e = \frac{\text{row total} \times \text{column total}}{\text{grand total}}
Learn thisH0\mathrm{H}_0 is the no-effect claim: independent, fits the claimed distribution, or μ1=μ2\mu_1 = \mu_2 for population means.
Learn thisReject H0\mathrm{H}_0 when the p-value is less than the significance level, or χcalc2\chi^2_{\text{calc}} is greater than the critical value.
Learn thisExpected frequencies are what H0\mathrm{H}_0 predicts. The test needs every expected frequency greater than 55: SL exam questions always meet this; at HL you may need to merge classes first.
Learn thisχ² tests use the upper tail only. df =(r−1)(c−1)= (r - 1)(c - 1) for an r×cr \times c contingency table; df =n−1= n - 1 for goodness of fit at SL (nn categories).
Learn thisSL t-test: pooled two-sample, unpaired samples, normal populations, equal population variances. ≠\neq is two-tailed; >> or << is one-tailed.
Learn thisEvery conclusion gives the comparison, the decision and its meaning in context.

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)

Practise Chi-squared tests →