SECTION 1
Historical Context & Motivation
Statistics often asks a deceptively simple question: does what we observe match what we expect? Imagine rolling a die 60 times and recording how often each face appears. If the die is fair, you'd expect about 10 of each outcome. But suppose you get 15 sixes — is that suspicious, or just normal randomness? The chi-squared distribution gives us a rigorous way to answer that question. It provides a mathematical framework for deciding whether differences between observed and expected frequencies are statistically significant or merely due to chance.
1875 • Friedrich Helmert's Foundation
1900 • Karl Pearson's Goodness-of-Fit Test
1922 • Ronald Fisher's Refinements
1954 • Test of Independence
The central question the chi-squared distribution addresses is this: when we collect categorical data and compare it to a theoretical model, how large must the discrepancy be before we conclude that the model is wrong? This question sits at the heart of statistical inference and is the focus of IB AHL topic 4.10.
SECTION 2
Core Principles & Definitions
Before diving into calculations, you need to understand several foundational ideas that make the chi-squared test work. These concepts will appear repeatedly throughout this topic, so take your time with each one.
Observed vs. Expected Frequencies
Degrees of Freedom (ν)
The Null Hypothesis (H₀)
Significance Level (α)
The p-value
KEY TAKEAWAY
SECTION 3
Visualizing the Chi-Squared Distribution
The chi-squared distribution is not symmetric like the normal distribution. Instead, it is right-skewed, starting at zero and stretching to the right. Its shape changes dramatically depending on the degrees of freedom (ν). With low degrees of freedom, the curve is steeply peaked near zero and has a long right tail. As ν increases, the distribution becomes more symmetric and begins to resemble a normal distribution.
When interpreting a chi-squared test, you focus on the right tail of the distribution. A large χ² value means the observed data deviates substantially from the expected data. The p-value tells you the area under the curve to the right of your calculated χ² value. If that area is smaller than your chosen significance level α, you reject the null hypothesis.
Important for IB Exams
SECTION 4
Mathematical Framework
The mathematics behind the chi-squared test is surprisingly straightforward. The test statistic measures how far your observed data deviates from what you'd expect, scaled appropriately so that the result follows a known distribution.
CHI-SQUARED TEST STATISTIC
where fₒ = observed frequency, fₑ = expected frequency, and the sum is taken over all categories. Each term measures the squared discrepancy between what you observed and what you expected, divided by the expected value for that category.
Let's break down why this formula works. The numerator (fₒ − fₑ)² captures the size of the discrepancy. We square it so that positive and negative deviations don't cancel each other out. The denominator fₑ scales the contribution: a deviation of 5 is much more meaningful when you only expected 10 occurrences than when you expected 1000. This scaling ensures every category contributes fairly to the total.
DEGREES OF FREEDOM (GOODNESS-OF-FIT)
where k = the number of categories. We subtract 1 because once you know k − 1 frequencies and the total, the last frequency is determined.
EXPECTED FREQUENCY (GOODNESS-OF-FIT)
where n = total number of observations and pᵢ = the hypothesized probability for category i. For a fair die with 60 rolls: fₑ = 60 × (1/6) = 10 for each face.
DECISION RULE
The critical value χ²critical is found from chi-squared tables (or your GDC) using ν and the chosen significance level α. Equivalently, if the p-value < α, reject H₀.
Conditions for Using the Chi-Squared Test
SECTION 5
Chi-Squared Critical Values & Decision Making
In the IB, you will typically compare your calculated χ² value against a critical value from a table or use your GDC to find the p-value directly. The table below shows commonly used critical values for selected degrees of freedom and significance levels.
| Degrees of Freedom (ν) | α = 0.10 | α = 0.05 | α = 0.01 |
|---|---|---|---|
| 1 | 2.706 | 3.841 | 6.635 |
| 2 | 4.605 | 5.991 | 9.210 |
| 3 | 6.251 | 7.815 | 11.345 |
| 4 | 7.779 | 9.488 | 13.277 |
| 5 | 9.236 | 11.070 | 15.086 |
| 6 | 10.645 | 12.592 | 16.812 |
Chi-squared critical values for common degrees of freedom and significance levels
When using your GDC (graphing calculator), you can compute the p-value directly with a chi-squared CDF function. On a TI-84, you would use χ²cdf(χ²calc, 10^99, ν) to get the p-value. If p-value < α, you reject H₀. This approach is often faster than looking up critical values in a table.
SECTION 6
Worked Example: Goodness-of-Fit Test
A candy company claims that its bags contain the following colour distribution: 30% red, 20% blue, 20% green, 15% yellow, and 15% orange. A student buys a bag of 200 candies and counts the following: 75 red, 35 blue, 40 green, 28 yellow, and 22 orange. At a 5% significance level, test whether the observed distribution matches the company's claim.
Chi-Squared Goodness-of-Fit Test
- 1
Step 1 — State the Hypotheses
H₀: The observed colour distribution matches the company's claimed proportions (30% red, 20% blue, 20% green, 15% yellow, 15% orange). H₁: The observed colour distribution does not match the claimed proportions. - 2
Step 2 — Calculate Expected Frequencies
Using fₑ = n × pᵢ with n = 200: Red: 200 × 0.30 = 60. Blue: 200 × 0.20 = 40. Green: 200 × 0.20 = 40. Yellow: 200 × 0.15 = 30. Orange: 200 × 0.15 = 30. All expected frequencies are ≥ 5, so the test conditions are satisfied.fₑ: 60, 40, 40, 30, 30 — all ≥ 5 ✓ - 3
Step 3 — Compute Each (fₒ − fₑ)² / fₑ Term
Red: (75 − 60)² / 60 = 225 / 60 = 3.750. Blue: (35 − 40)² / 40 = 25 / 40 = 0.625. Green: (40 − 40)² / 40 = 0 / 40 = 0.000. Yellow: (28 − 30)² / 30 = 4 / 30 = 0.133. Orange: (22 − 30)² / 30 = 64 / 30 = 2.133.Individual contributions: 3.750, 0.625, 0.000, 0.133, 2.133 - 4
Step 4 — Sum to Find χ²calc
χ²calc = 3.750 + 0.625 + 0.000 + 0.133 + 2.133 = 6.641χ²calc = 6.641 - 5
Step 5 — Find Degrees of Freedom and Critical Value
There are k = 5 categories, so ν = 5 − 1 = 4. At α = 0.05 with ν = 4, the critical value from the table is χ²critical = 9.488.ν = 4, χ²critical = 9.488 - 6
Step 6 — Make a Decision
Since χ²calc = 6.641 < χ²critical = 9.488, we do not reject H₀. There is insufficient evidence at the 5% significance level to conclude that the colour distribution differs from the company's claim. Using a GDC, the p-value ≈ 0.156, which is greater than 0.05.Do not reject H₀. The data is consistent with the company's claimed proportions.
SECTION 7
Strengths, Limitations & Common Mistakes
The chi-squared test is one of the most versatile tools in statistics, but it has clear limitations that you must understand, especially for IB exam questions that ask you to evaluate the appropriateness of a test.
| Strengths | Limitations |
|---|---|
| Works with categorical (non-numerical) data that many other tests cannot handle | Requires all expected frequencies to be at least 5; small samples may need categories combined |
| Easy to compute by hand or with a GDC — no complex algebra required | Cannot tell you which category is responsible for a significant result — only that a difference exists |
| Applicable to many real-world scenarios: genetics, surveys, quality control | Sensitive to sample size: very large samples may flag trivial differences as significant |
| Makes minimal assumptions about the underlying distribution of the data | Data must be raw frequencies (counts), not percentages, means, or ranks |
| Well-understood with widely available critical value tables | Observations must be independent — paired or repeated-measures data violates this assumption |
Comparison of chi-squared test strengths and limitations
COMMON EXAM MISTAKE
SECTION 8
Connection to Other Statistical Tests & Advanced Theory
The chi-squared goodness-of-fit test is just the starting point. In IB Mathematics HL and beyond, the same distribution underpins other important procedures. Understanding how these relate to each other will deepen your appreciation of why the chi-squared distribution is so central to statistical inference.
| Feature | Goodness-of-Fit Test (AHL 4.10) | Test of Independence (Extension) |
|---|---|---|
| Purpose | Tests whether data fits a specific theoretical distribution | Tests whether two categorical variables are associated |
| Data layout | One row of observed vs. expected frequencies | Two-way contingency table (r × c) |
| Degrees of freedom | ν = k − 1 | ν = (r − 1)(c − 1) |
| Expected frequency formula | fₑ = n × pᵢ | fₑ = (row total × column total) / grand total |
| H₀ | Data follows the specified distribution | The two variables are independent |
Comparing the goodness-of-fit test with the test of independence
Beyond the IB syllabus, the chi-squared distribution also appears in confidence intervals for variance, in the likelihood ratio test used in advanced regression analysis, and in machine learning algorithms that select features for classification models. The mathematical foundation you build here with goodness-of-fit testing transfers directly to these more sophisticated applications, making this one of the most practical distributions you will study.
IB Exam Connection
SECTION 9
Practice Problems
Question 1: CONCEPTUAL
Show answer
Question 2: BASIC CALCULATION
Show answer
Question 3: INTERMEDIATE
Show answer
Question 4: APPLIED
Show answer
Question 5: CRITICAL THINKING
Show answer
SUMMARY
Lesson Summary
Summary
The chi-squared goodness-of-fit test determines whether observed frequencies differ significantly from expected frequencies predicted by a null hypothesis. The test statistic χ²calc = Σ (fₒ − fₑ)² / fₑ follows a chi-squared distribution with ν = k − 1 degrees of freedom. The distribution is always right-skewed and takes only non-negative values, with its shape depending entirely on ν.
To perform the test, compare χ²calc to the critical value from the chi-squared table at your chosen significance level α, or compare the p-value to α. If χ²calc > χ²crit (or p-value < α), reject H₀. Remember: all expected frequencies must be ≥ 5, data must be raw counts, and observations must be independent. Always state your conclusion in context and write 'do not reject H₀' rather than 'accept H₀.'