← All notesMaths AI · Chi-squared and t-tests⬇ Download PDF
IB DP Maths AI · Topic 4 Statistics and probability · SL 4.11 · ~6 min read

Chi-squared and t-tests

Hypothesis testing for IB Maths AI: null and alternative hypotheses, significance levels and p-values, the χ² test for independence with contingency tables and degrees of freedom, the χ² goodness of fit test, and the two-sample t-test with one- and two-tailed alternatives, all with GDC steps and conclusions in context.

Null & alternative hypothesesSignificance levelp-valuesCritical valuesContingency tablesExpected frequenciesDegrees of freedomχ² test for independence
RSby Riyaz Sir
mentorriyaz.in
No tag = SL and HLHL ONLY HL students onlyFORMULA BOOKLET given in the examM1A1 how marks are awardedhighlight = comes up again and againTest yourself at the end

In 30 seconds

  • A hypothesis test starts from H0 (no effect, no difference, independent) and asks whether the data is unlikely enough to reject it.
  • Decision rule: if the p-value < significance level (usually 5%), reject H0. Equivalently, reject if the test statistic is beyond the critical value.
  • χ² test for independence: compare observed frequencies in a contingency table with the expected frequencies E = row total × column totalgrand total. Degrees of freedom = (rows − 1)(columns − 1).
  • χ² goodness of fit: compare observed frequencies with those a model (uniform, binomial, normal) predicts. Degrees of freedom = number of categories − 1 (for the AI course, where no parameters are estimated).
  • t-test: compares the means of two independent samples from normal populations. Use a one-tailed test when H1 says "greater" or "less", two-tailed for "different".

By the end you can

  • Write null and alternative hypotheses, and understand significance levels and p-values.
  • Find expected frequencies and degrees of freedom for a contingency table.
  • Carry out and interpret a χ² test for independence.
  • Carry out and interpret a χ² goodness of fit test.
  • Carry out and interpret a t-test for the difference of two means, one- or two-tailed.
  • Write conclusions in context.

1The language of hypothesis tests

TermMeaning
H0null hypothesis: no association, no difference
H1alternative hypothesis: what you suspect
significance levelthe probability of rejecting H0 when it is true (5% unless told)
p-valuethe probability of a result at least this extreme if H0 is true
critical valuethe boundary of the rejection region for the test statistic
Common mistakeWriting "accept H0". The data never proves H0; you do not reject it, because there is not enough evidence against it.

2χ² test for independence

χ2calc = Σ (fo − fe)2fe FORMULA BOOKLET
fo observed, fe expected frequency
MathsScienceArtsTotal
Year 1130251570
Year 1220352580
Total506040150
Worked example

Test at the 5% level whether favourite subject is independent of year group.

  1. H0: favourite subject and year group are independent; H1: they are not independent A1
  2. expected Year 11 Maths = 70 × 50150 = 23.3, …; df = (2 − 1)(3 − 1) = 2 M1A1
  3. GDC χ² test: χ² = 5.52, p = 0.0631 A1
  4. 0.0631 > 0.05, so do not reject H0: there is not enough evidence at 5% that favourite subject depends on year group R1
02468critical 5.99χ² = 5.525%χ² distribution, df = 25.52 < 5.99, p = 0.063do not reject H₀Reject H₀ only if the statistic falls in the red critical region (p < 0.05).
The χ² distribution with 2 degrees of freedom. 5.52 falls just short of the 5% critical region.
Exam tipExpected frequencies must be at least 5. If some are smaller, combine rows or columns (and recalculate the degrees of freedom).
GDC (calculator) methodPut the observed table in matrix A; the χ² test puts the expected values in matrix B. Write down at least one expected value, the degrees of freedom, χ² and p.

3χ² goodness of fit

Worked example

A die is rolled 60 times: 1 (8), 2 (12), 3 (9), 4 (7), 5 (14), 6 (10). Test at 5% whether it is fair.

  1. H0: the die is fair (each face has probability 16); H1: it is not fair A1
  2. expected 10 each, df = 6 − 1 = 5 A1
  3. χ² = 4 + 4 + 1 + 9 + 16 + 010 = 3.40, p = 0.639 M1A1
  4. p > 0.05 (and 3.40 < critical value 11.07): do not reject H0; there is no evidence the die is biased R1
  • Other models: for "the data follows B(4, 0.5)" or a normal model, find the expected frequencies from the model × total, then test in the same way.
Common mistakeUsing percentages instead of frequencies. χ² uses counts: convert probabilities to expected counts by multiplying by the total.

4The t-test for two means

55606570758085class B: 65.7class A: 72.7t = 2.88, p = 0.0070 (one-tailed): the difference in means is significant at 5%.
Two sample means 7 marks apart. Is that difference real or just sampling variation?
Worked example

Class A scored 72, 68, 75, 80, 66, 71, 77 and class B scored 65, 70, 62, 68, 64, 71, 60. Test at the 5% level whether class A's mean is greater. Assume normal populations with equal variances.

  1. H0: μA = μB; H1: μA > μB (one-tailed) A1
  2. 2-sample t-test, pooled: x̄A = 72.7, x̄B = 65.7, t = 2.88, p = 0.00697 M1A1
  3. p < 0.05, so reject H0: there is evidence that class A's mean score is higher R1
  • Two-tailed: for H1: μA ≠ μB, the p-value doubles (here 0.0139), and you compare with 5% in the same way.
  • Assumptions: both samples random and independent, both populations normally distributed. Mention them if asked to comment on the validity of the test.
Linking questionThe χ² test checks the models of Probability, binomial and normal distributions against data, and the t-test uses the ideas of sampling distributions from the central limit theorem (Estimation, Poisson, hypothesis tests and Markov chains, HL). Correlation in Statistics, correlation and regression tells you about a relationship; these tests tell you whether it is significant.
Idea for your IA / explorationSurvey students about two categorical variables (year group and preferred study method, gender and favourite sport) and run a χ² test for independence, discussing expected frequencies, combining categories and the limits of your sample. Or compare reaction times of two groups with a t-test.

Test yourself — cover the answers first

Quick check

  1. What does H₀ say in a test for independence?
  2. Find df for a 3 × 4 contingency table.
  3. p = 0.03 at the 5% level. Decision?
  4. Expected frequency: row total 40, column total 30, grand total 120.
  5. Which H₁ gives a one-tailed t-test: "different" or "greater"?

Exam-style

  1. In a goodness of fit test with 4 categories, χ²calc = 9.2 and the 5% critical value for 3 df is 7.815. State and justify your conclusion.
  2. A contingency table has an expected frequency of 3.2 in one cell. What should you do, and why?
Show answers
  1. the two variables are independent
  2. 6
  3. reject H₀
  4. 10
  5. greater
  6. 9.2 > 7.815, so χ² is in the critical region
    reject H₀: there is evidence at the 5% level that the data does not fit the model
  7. expected frequencies should be at least 5 for the χ² test to be valid
    combine that row or column with an adjacent one, then recalculate the degrees of freedom before testing
Stuck on a question?

Send it to me on WhatsApp. I read every message.

Want regular help? Send this to your parent →
Share with a friendAsk Riyaz Sir

Independent notes written by Riyaz Sir. Not produced, endorsed or approved by the International Baccalaureate Organization. Syllabus codes refer to the IB DP subject guides.