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.
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.
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
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.
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.
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.
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 |
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.
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.
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 |
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 |
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.
Practice Problems
Lesson 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₀.'