Skip to content
IB Diploma ProgrammeSL & HL

Hypothesis testing and chi-squared

Mathematics: Applications and Interpretation SL & HL Chapter Notes

Last updated November 2026

ShareWhatsAppPost

Hypothesis testing and chi-squared notes as a printable PDF.

Read online free. Download a watermarked copy with a free account.

Read the notes

The full Hypothesis testing and chi-squared notes as text: skim, search, and jump between subtopics.

~20 min read

1. Null and alternative hypotheses

A hypothesis test starts with two statements. The null hypothesis H₀ is the statement tested: no association, equal means, or data that follows a stated distribution. The alternative hypothesis H₁ is the negative of H₀.

Write them as an equation or inequality, or in words. For a chi² test for independence, H₀ says one variable is independent of the other. H₁ says it is not independent. The markscheme accepts associated and dependent for the second wording. It rejects "correlated" and "related".

The command term *state* asks for the two statements with the variables named in context. If the two are written the wrong way round, only one of the two marks is earned.

H₀: variable A is independent of variable B

H₁: variable A is not independent of variable B

H₀: μ_A = μ_B H₁: μ_A < μ_B

Worked example 12 marks

A school librarian conducts a survey to determine the favourite genre of book within different age groups. A group of 230 students was asked to state their age and their favourite from three genres of books: mystery, science fiction and romance. A chi² test at the 5% significance level is carried out to determine if a student's favourite genre of book is independent of their age.

(a) State the(i) null hypothesis.(ii) alternative hypothesis.

  1. 1

    (a)(i) A1: H₀: favourite genre of book is independent of age [1]

  2. 2

    (a)(ii) A1: H₁: favourite genre of book is not independent of age [1]

2. Significance levels and p-values

A significance level is the threshold the question gives: 1%, 5% or 10%. The p-value comes from technology. Both are numbers, so a decision is a comparison of two numbers.

If the p-value is less than the significance level, reject H₀. Otherwise there is insufficient evidence to reject it. Only upper tail chi² tests are set, so a large chi² value means a small p-value.

The markscheme gives one mark for the comparison (R1) and one for the conclusion in context (A1). Write the inequality with both numbers seen. A conclusion with no comparison earns no mark.

p < significance level ⇒ reject H₀

Worked example 14 marks

A school librarian conducts a survey to determine the favourite genre of book within different age groups. A group of 230 students was asked to state their age and their favourite from three genres of books: mystery, science fiction and romance. The data is summarized in the following table.

A chi² test at the 5% significance level is carried out to determine if a student's favourite genre of book is independent of their age.

(b) Find the p-value for this test.

(c) State, in context, the conclusion for this test. Justify your answer.

MysteryScience fictionRomance
< 13 years old265222
13 to 16 years old223119
> 16 years old281713
  1. 1

    (b) A2: p = 0.0336 (0.0336233…) from technology. A rounded 0.034 earns A1A0 [2]

  2. 2

    (c) R1: 0.0336 < 0.05 [1]

  3. 3

    (c) A1: reject H₀, so favourite genre of book is not independent of age [1]

3. Observed and expected frequencies

Observed frequencies are the counts in the data. Expected frequencies are the counts H₀ predicts. In a contingency table, find an expected frequency from the row total, the column total and the grand total.

In the examination technology gives the chi² statistic. The syllabus notes say hand calculation may enhance understanding. The expected frequencies in examination questions will be greater than 5. For an IA, know the limits of the test when an expected frequency is 5 or less.

The markscheme credits evidence of finding expected frequencies as a method mark. Write the product and the division, then the value.

E = (row total × column total)/(grand total)

chi²_calc = sum ((O - E)²)/E

Worked example 13 marks

A survey asks 200 students which language they study. The results are in the following table.

(a) Find the expected frequency for Year 10 students who study French.

(b) Find the contribution of this cell to the chi² statistic, using ((O - E)²)/E from the formula booklet.

FrenchSpanishGermanTotal
Year 10423622100
Year 11284428100
Total708050200
  1. 1

    (a) M1: E = (100 × 70)/200, the row total times the column total over the grand total [1]

  2. 2

    (a) A1: E = 35 [1]

  3. 3

    (b) A1: ((42 - 35)²)/35 = 49/35 = 1.4 [1]

4. The chi-squared test for independence

A contingency table shows the counts for two categorical variables. The test asks if they are independent. In examinations a table has at most 4 rows or columns, and the degrees of freedom are greater than 1.

For r rows and c columns the degrees of freedom are (r-1)(c-1). The 4 colours and 3 age groups below give (3-1)(4-1) = 6, the degrees of freedom for the critical value 16.81.

Two decisions are credited. Either chi²_calc is greater than the critical value, or the p-value is less than the significance level. The markscheme says the p-value and the level must both be explicitly stated. The conclusion must agree with the chi²_calc the student found.

degrees of freedom = (r - 1)(c - 1)

chi²_calc > critical value ⇒ reject H₀

Worked example 15 marks

A car manufacturer collected data about preferred car colour from drivers in various age groups. The results are presented in the following table.

(a) Write down the value of b.

The car manufacturer performs a chi² test for independence, at the 1% significance level, to determine if there is significant evidence that different age groups have different car colour preferences. The null hypothesis and alternative hypothesis are defined as:

H₀: age and car colour preference are independent.

H₁: age and car colour preference are not independent.

The chi² critical value for this test is 16.81.

(b) Find the chi² test statistic.

(c) Write down the conclusion to the test, in context. Give a reason for your answer.

WhiteBlackSilverRedTotal
18 ≤ Age < 2512741740
25 ≤ Age < 4515b101258
Age ≥ 45121816652
Total39463035150
  1. 1

    (a) A1: b = 58 - 15 - 10 - 12 = 21 [1]

  2. 2

    (b) A2: chi²_calc = 18.3 (18.3313…) from technology [2]

  3. 3

    (c) R1: 18.3 > 16.81 (or p = 0.00546 < 0.01, with both numbers stated) [1]

  4. 4

    (c) A1: reject H₀: there is sufficient evidence that age and car colour preference are not independent [1]

5. The chi-squared goodness of fit test

The goodness of fit test checks whether observed data follow a stated distribution. H₀ says the data follow the distribution described by the stated probabilities. H₁ says they do not.

Each expected frequency is the number of trials times the stated probability. If an expected frequency is 5 or less, merge categories first. Mathilda merged three prize columns so that all expected frequencies were greater than 5.

At SL the degrees of freedom are n - 1, where n is the number of categories after merging. The markscheme rejects vague hypotheses such as "the prize probabilities are as expected". It accepts a conclusion only in context. "Do not reject H₀" alone does not earn the conclusion mark.

E_i = N × p_i

degrees of freedom = n - 1

Worked example 16 marks

Mathilda wants to determine whether the probability of winning each prize matches the lottery company's claims. She records the prizes from 750 scratchcards. She decides to perform a chi² goodness of fit test at the 10% significance level. To ensure that her expected frequencies are all greater than 5, Mathilda merges the data for the 10, 100 and 500 USD prizes into one column, in the following table. The row of probabilities is the lottery company's claim.

(e)(i) Write down the null and the alternative hypothesis for Mathilda's test.(ii) Find the p-value for the test.(iii) State the conclusion of Mathilda's test in context. Justify your answer.

Prize (USD)02510, 100, 500
Number of scratchcards6924873
Lottery company's probability0.8960.0850.0120.007
  1. 1

    (i) A1: H₀: the collected data follows the distribution described by the probabilities claimed by the lottery company. H₁: it does not [1]

  2. 2

    (ii) (A1): degrees of freedom = 3 seen [1]

  3. 3

    (ii) (M1): expected frequencies, 750 × 0.896 = 672, 63.75, 9 and 5.25 [1]

  4. 4

    (ii) A1: p-value = 0.117 (0.116824…) [1]

  5. 5

    (iii) R1: 0.116824 > 0.10 [1]

  6. 6

    (iii) A1: insufficient evidence to say the data does not follow the distribution claimed by the lottery company [1]

6. The t-test for two means

The t-test compares the means of two populations using two unpaired samples. At SL the population variance is unknown. Assume the two groups have equal variance and use the pooled two-sample test.

The underlying distribution of each variable must be normal. Mysha's question states this assumption. Technology does the calculation and gives the p-value.

H₀ says the population mean of one group is the same as the other. A one-tailed H₁ says it is less than (or greater than) the other. Compare the p-value with the significance level, then write the conclusion about the population means in context. The markscheme follows through from the student's p-value in the conclusion.

H₀: μ_A = μ_N H₁: μ_A < μ_N

Worked example 16 marks

For her study on fitness levels, Mysha randomly selects a group of participants from her local community. She asks each participant to classify their lifestyle as "active" or "non-active". She then measures the heart rate of each participant after they have run for 10 minutes on a treadmill at a set speed. The heart rates, in beats per minute, are in the following table.

Mysha believes that the mean heart rate of active lifestyle participants, μ_A, will be lower than the mean heart rate of non-active lifestyle participants, μ_N. She assumes that the heart rates are normally distributed and performs a one-tailed t-test at the 5% level of significance.

(c) State(i) the null hypothesis.(ii) the alternative hypothesis.

(d) Find the p-value for this test.

(e) State the conclusion for this test in context. Justify your answer.

Heart rate (beats per minute)
Active lifestyle121115130128110112135127
Non-active lifestyle133142121140138118124135
  1. 1

    (c)(i) A1: H₀: μ_A = μ_N, or the population mean heart rate of active people is the same as that of non-active people [1]

  2. 2

    (c)(ii) A1: H₁: μ_A < μ_N, or it is less [1]

  3. 3

    (d) A2: p-value = 0.0331 (0.0331372…) [2]

  4. 4

    (e) R1: 0.0331 < 0.05 [1]

  5. 5

    (e) A1: reject H₀: the population mean heart rate of active people is less than that of non-active people [1]

7. One-tailed and two-tailed tests

The sign in H₁ sets the tail. < or > gives a one-tailed test. ≠ gives a two-tailed test. Write H₁ to match the claim: "lower than" gives <, "different from" gives ≠.

Set technology to the same alternative as H₁, then read off its p-value and compare it with the significance level. A wrong setting gives a different p-value and can flip the decision. chi² questions use the upper tail only.

Mysha's claim, "lower", was one-tailed: her H₁ said the mean heart rate of active people is less than that of non-active people. A claim of "different" is two-tailed and H₁ then has ≠.

Worked example 14 marks

A bakery compares the mean mass of loaves from machine P and machine Q. The masses are normally distributed with equal variances. A two-tailed pooled t-test is done at the 5% significance level. Technology gives a p-value of 0.0412.

(a) State the null and alternative hypotheses.

(b) State the conclusion in context. Justify your answer.

  1. 1

    (a) A1: H₀: μ_P = μ_Q, the mean masses are the same [1]

  2. 2

    (a) A1: H₁: μ_P ≠ μ_Q, the mean masses are different [1]

  3. 3

    (b) R1: 0.0412 < 0.05 [1]

  4. 4

    (b) A1: reject H₀: there is sufficient evidence that the mean mass of loaves differs between the machines [1]

Recap

  • H₁ is the negative of H₀. Use "independent" and "not independent", never "related" or "correlated".
  • Decide by comparing two numbers: p with the significance level, or chi²_calc with the critical value. Write both numbers.
  • Expected frequency = (row total × column total)/(grand total). Merge categories when it is 5 or less.
  • Independence: degrees of freedom (r-1)(c-1). Goodness of fit: n - 1.
  • t-test at SL: unpaired, pooled, normal. Give the conclusion about the population means in context.
  • Set the technology's alternative to match H₁: < or > is one-tailed, ≠ is two-tailed.

End-of-chapter exercise

Test yourself on the whole chapter. Work through these before moving on.

  1. State the null hypothesis for a chi² test for independence of a student's favourite sport (football, tennis or swimming) and the student's gender.1 mark
    Answer
    1. H₀: favourite sport is independent of gender.

    Trap: Writing "favourite sport is not related to gender", a wording the markscheme rejects.

  2. A chi² test at the 1% significance level tests whether a parcel's delivery outcome (on time or late) is independent of the courier (A, B or C). The p-value is 0.048. State the conclusion in context. Justify your answer.2 marks
    Answer
    1. 0.048 > 0.01.
    2. Do not reject H₀: there is insufficient evidence that delivery outcome and courier are not independent.

    Trap: Comparing 0.048 with 5% out of habit. The level in the question is 1%.

  3. A survey asks 200 people how they travel to work. The results are in the following table. (a) Find the expected frequency for Town B and walking. (b) Find the contribution of this cell to the chi² statistic, using ((O - E)²)/E. | | Walk | Cycle | Bus | Total | | --- | --- | --- | --- | --- | | Town A | 30 | 24 | 46 | 100 | | Town B | 20 | 36 | 44 | 100 | | Total | 50 | 60 | 90 | 200 |3 marks
    Answer
    1. (a)
    2. E = (100 × 50)/200.
    3. E = 25.
    4. (b)
    5. ((20 - 25)²)/25 = 25/25 = 1.

    Trap: Leaving out the division by the grand total and answering 100 × 50 = 5000.

  4. A shop records the type of drink bought (four types) by customers in three age groups. A chi² test for independence at the 5% significance level gives chi²_calc = 12.9. The critical value is 12.59. (a) Write down the degrees of freedom. (b) State the conclusion in context. Justify your answer.3 marks
    Answer
    1. (a)
    2. (3 - 1)(4 - 1) = 6.
    3. (b)
    4. 12.9 > 12.59.
    5. Reject H₀: the type of drink bought is not independent of age group.

    Trap: Taking the degrees of freedom as the number of cells minus one, 12 - 1 = 11, and so using the wrong critical value.

  5. A gym asks its members about their membership type (three types) and their age group (three groups). A chi² test for independence is carried out at the 10% significance level. Technology gives chi²_calc = 7.84 and a p-value of 0.0976. (a) State the null and alternative hypotheses. (b) State the conclusion in context. Justify your answer.4 marks
    Answer
    1. (a)
    2. H₀: membership type is independent of age group.
    3. H₁: membership type is not independent of age group.
    4. (b)
    5. 0.0976 < 0.10.
    6. Reject H₀: membership type is not independent of age group.

    Trap: Reversing the two hypotheses, which keeps only one mark, or comparing 0.0976 with 5%.

  6. A two-tailed pooled t-test at the 5% significance level compares the mean fuel use of two models of car. The fuel use of each model is normally distributed with equal variances. Technology gives a p-value of 0.062. (a) State the null and alternative hypotheses. (b) State the conclusion in context. Justify your answer.4 marks
    Answer
    1. (a)
    2. H₀: μ₁ = μ₂.
    3. H₁: μ₁ ≠ μ₂.
    4. (b)
    5. 0.062 > 0.05.
    6. Do not reject H₀: there is insufficient evidence that the mean fuel use of the two models is different.

    Trap: Writing "accept H₀, so the means are equal". The test finds insufficient evidence, not proof of equality.

  7. A die is rolled 120 times. The scores 1 to 6 occur 14, 22, 25, 18, 16 and 25 times. A chi² goodness of fit test at the 10% significance level tests whether the die is fair. Technology gives chi²_calc = 5.5. The critical value is 9.24. (a) State the null hypothesis. (b) Write down the expected frequency for each score. (c) Write down the degrees of freedom. (d) State the conclusion in context. Justify your answer.5 marks
    Answer
    1. (a)
    2. H₀: the scores follow the distribution of a fair die, with P(each score) = 1/6.
    3. (b)
    4. E = 120 × 1/6 = 20.
    5. (c)
    6. 6 - 1 = 5.
    7. (d)
    8. 5.5 < 9.24.
    9. Do not reject H₀: there is insufficient evidence that the die is not fair.

    Trap: Taking the degrees of freedom as 6, the number of categories, instead of n - 1 = 5, and so using the wrong critical value.

  8. A teacher believes that background music reduces the mean time taken to complete a puzzle. Six students did the puzzle with music (group A) and six in silence (group B). The times, in minutes, are in the following table. Assume the two groups have equal variances. A pooled t-test is done at the 5% significance level. (a) State the null and alternative hypotheses. (b) State the assumption about the distribution of the times that this test needs. (c) Find the p-value for the test. (d) State the conclusion in context. Justify your answer. | Time (minutes) | | | | | | | | --- | --- | --- | --- | --- | --- | --- | | Group A, music | 12 | 15 | 14 | 16 | 13 | 17 | | Group B, silence | 15 | 17 | 16 | 19 | 14 | 18 |7 marks
    Answer
    1. (a)
    2. H₀: μ_A = μ_B.
    3. H₁: μ_A < μ_B, a one-tailed test.
    4. (b)
    5. The times in each group are normally distributed.
    6. (c)
    7. Technology, one-tailed: p = 0.0469.
    8. (d)
    9. 0.0469 < 0.05.
    10. Reject H₀: there is sufficient evidence that the mean time with music is less than the mean time in silence.

    Trap: Leaving the technology on its two-tailed setting, reading p = 0.0938 and wrongly not rejecting H₀.

  9. A transport planner asks commuters where they live and how they usually travel. The results are in the following table, where x is unknown. The expected frequency for city commuters who take the train is 43. A chi² test for independence is done at the 5% significance level. (a) Show that x = 40. (b) State the null and alternative hypotheses. (c) Find the p-value for the test. (d) State the conclusion in context. Justify your answer. | | Car | Train | Bike | Total | | --- | --- | --- | --- | --- | | City | x | 50 | 30 | 80 + x | | Suburb | 60 | 36 | 24 | 120 | | Total | 60 + x | 86 | 54 | 200 + x |9 marks
    Answer
    1. (a)
    2. ((80 + x) × 86)/(200 + x) = 43.
    3. 86(80 + x) = 43(200 + x), so 2(80 + x) = 200 + x.
    4. 160 + 2x = 200 + x, so x = 40.
    5. (b)
    6. H₀: usual travel method is independent of where the commuter lives.
    7. H₁: usual travel method is not independent of where the commuter lives.
    8. (c)
    9. With x = 40: technology gives chi²_calc = 6.95 with (2-1)(3-1) = 2 degrees of freedom, so p = 0.0310.
    10. (d)
    11. 0.0310 < 0.05.
    12. Reject H₀: usual travel method is not independent of where the commuter lives.

    Trap: Expanding 43(200 + x) as 8600 + x, which gives 85x = 1720 and a count that is not a whole number; or writing "not related" in H₀, which the markscheme rejects.

  10. A café owner states that 40% of customers buy a small coffee, 35% a medium, 20% a large and 5% an extra large. In one day 80 customers buy 30 small, 32 medium, 13 large and 5 extra large coffees. A chi² goodness of fit test at the 5% significance level tests the owner's statement. (a) Show that an expected frequency is not greater than 5. Hence state why the large and extra large columns are merged. (b) State the null hypothesis. (c) Write down the expected frequencies after merging. (d) Write down the degrees of freedom. (e) Find the chi² statistic. (f) Technology gives a p-value of 0.639. State the conclusion in context. Justify your answer.8 marks
    Answer
    1. (a)
    2. Extra large: 80 × 0.05 = 4, which is 5 or less.
    3. The expected frequency must be greater than 5, so the columns are merged.
    4. (b)
    5. H₀: the data follows the distribution of sizes the owner states.
    6. (c)
    7. 32, 28 and 20, with large and extra large merged: 80 × 0.25 = 20.
    8. (d)
    9. 3 - 1 = 2.
    10. (e)
    11. ((30 - 32)²)/32 + ((32 - 28)²)/28 + ((18 - 20)²)/20.
    12. = 0.125 + 0.571 + 0.2 = 0.896.
    13. (f)
    14. 0.639 > 0.05.
    15. Do not reject H₀: there is insufficient evidence that the sizes bought do not follow the distribution the owner states.

    Trap: Using 4 - 1 = 3 degrees of freedom, the number of categories before merging, and not 2 after.

Say this, not that

Wording that loses the mark, against the wording the mark scheme credits.

Loses the markGets the mark
H₀: favourite genre is not related to age, or not correlated with ageH₀: favourite genre is independent of age, or not associated with it
"Do not reject H₀" on its ownThere is insufficient evidence to say the data does not follow the distribution claimed, in context
The prize probabilities are as expectedThe collected data follows the distribution described by the probabilities claimed
p = 0.034, rounded to two significant figuresp = 0.0336, to three significant figures, with 0.0336 < 0.05 written

Frequently asked questions

How do you write the null and alternative hypotheses for a chi-squared test for independence?
The null hypothesis H₀ says the two variables are independent, and the alternative H₁ is its negative, that they are not independent. Use the words "independent" and "not independent", never "related" or "correlated". For favourite genre and age, H₀ is that favourite genre of book is independent of age.
How do you decide whether to reject the null hypothesis using a p-value?
Compare the p-value with the significance level: if p is less than the significance level, reject H₀. Write both numbers in the decision. With p = 0.0336 and a significance level of 0.05, 0.0336 < 0.05, so reject H₀. Give p to three significant figures, since a rounded 0.034 earns fewer marks.
How do you calculate an expected frequency and the chi-squared contribution of a cell?
The expected frequency is E = (row total × column total)/(grand total). The contribution of a cell is ((O - E)²)/E, where O is the observed frequency. For E = (100 × 70)/200 = 35 and O = 42, the contribution is ((42 - 35)²)/35 = 1.4.
How do you find the degrees of freedom for a chi-squared test of independence?
For r rows and c columns the degrees of freedom are (r - 1)(c - 1). For a table with 3 rows and 4 columns, the degrees of freedom are (3 - 1)(4 - 1) = 6. Do not use the number of cells minus one, which gives the wrong critical value. For a goodness of fit test, the degrees of freedom are n - 1.
How do you state the conclusion of a goodness of fit test about a claimed distribution?
The null hypothesis says the collected data follow the distribution described by the probabilities claimed. If the p-value is above the significance level, write that there is insufficient evidence to say the data does not follow the distribution claimed, in context. Do not write "do not reject H₀" on its own. For p = 0.117 > 0.10, there is insufficient evidence.
What does the sign in the alternative hypothesis change in a t-test?
The sign in H₁ sets the tail. A < or > gives a one-tailed test, and ≠ gives a two-tailed test. Set the technology to the same alternative as H₁, otherwise the p-value is wrong. A one-tailed test gives p = 0.0469 where the two-tailed setting gives p = 0.0938, and the decision at 0.05 changes.

Free notes are just the start.

Unlock every Workbook and Chapter at a Glance, and generate your own worksheets and predicted papers.

Explore plans

Related chapters