IB MATHEMATICS: ANALYSIS AND APPROACHES • STATISTICS AND PROBABILITY

Chi-Squared Distribution — AHL 4.10 Chi-squared distribution and inference (HL) (intro where applicable)

Learn how the chi-squared test reveals whether observed data fits an expected pattern or differs significantly.

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
German mathematician Friedrich Helmert derived the sampling distribution of the sample variance, laying the groundwork for chi-squared theory, though the connection would not be fully recognized for decades.
1900
Karl Pearson's Goodness-of-Fit Test
Karl Pearson published his landmark paper introducing the chi-squared goodness-of-fit test, giving scientists a tool to compare observed data against theoretical models. This is considered the birth of modern statistical testing.
1922
Ronald Fisher's Refinements
R. A. Fisher formalized the concept of degrees of freedom and clarified when and how the chi-squared test should be applied, correcting some of Pearson's original assumptions.
1954
Test of Independence
The chi-squared test was extended to contingency tables, enabling researchers to test whether two categorical variables are independent. This became one of the most widely used statistical procedures in biology, medicine, and the social sciences.

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.

1

Observed vs. Expected Frequencies

Observed frequencies (fo) are the actual counts from your data. Expected frequencies (fe) are the counts you'd predict under a specific hypothesis, such as 'the die is fair' or 'the proportions are equal.'
2

Degrees of Freedom (ν)

The degrees of freedom (ν, pronounced 'nu') represent the number of independent categories that can vary freely. For a goodness-of-fit test with k categories: ν = k − 1. The shape of the chi-squared distribution depends entirely on ν.
3

The Null Hypothesis (H₀)

The null hypothesis states that there is no significant difference between observed and expected frequencies. We assume H₀ is true and ask: how likely is our data under this assumption?
4

Significance Level (α)

The significance level (α) is the probability threshold for rejecting H₀. In IB exams, α is typically 0.05 (5%) or 0.01 (1%). If the probability of our result is below α, we reject H₀.
5

The p-value

The p-value is the probability of obtaining a chi-squared statistic at least as extreme as the one calculated, assuming H₀ is true. A small p-value means the data is unlikely under the null hypothesis.
KEY TAKEAWAY
Think of the chi-squared test like a referee at a basketball game. The referee (the test) watches what happens on the court (observed data) and compares it to the rules of the game (expected data). Small fouls happen by chance and play continues (we fail to reject H₀). But if a player commits a major violation, the referee blows the whistle and calls a foul (we reject H₀). The significance level α is essentially the referee's threshold for how serious the violation must be before calling it.

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.

The chi-squared distribution for ν = 2, 4, 7, and 10. Notice how the curve is heavily right-skewed for low ν and becomes progressively more symmetric as ν increases. The peak of the distribution shifts to the right with more degrees of freedom.

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
The chi-squared test is always a one-tailed test (right tail). You never look at the left tail because only large values of χ² suggest a poor fit. A very small χ² value simply means the data fits the expected model well.

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
χ²calc = Σ (fₒ − fₑ)² / fₑ
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)
ν = k − 1
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)
fₑ = n × pᵢ
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
If χ²calc > χ²critical , reject H₀
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
For the chi-squared test to be valid: (1) the data must consist of frequencies (counts), not percentages or proportions; (2) observations must be independent; and (3) all expected frequencies should be at least 5. If any expected frequency is less than 5, you may need to combine categories.

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.

Chi-squared critical values for common degrees of freedom and significance levels
Degrees of Freedom (ν)α = 0.10α = 0.05α = 0.01
12.7063.8416.635
24.6055.9919.210
36.2517.81511.345
47.7799.48813.277
59.23611.07015.086
610.64512.59216.812
The decision regions for a chi-squared test with ν = 4 and α = 0.05. The green region represents values where we do not reject H₀. The red region (right of the dashed critical value line at χ² = 9.488) is the rejection region. If your calculated χ² falls in the red zone, the result is statistically significant.

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.

Chi-Squared Goodness-of-Fit Test
1
Step 1 — State the HypothesesH₀: 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 FrequenciesUsing 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ₑ TermRed: (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 ValueThere 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 DecisionSince χ²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.

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.

Comparison of chi-squared test strengths and limitations
StrengthsLimitations
Works with categorical (non-numerical) data that many other tests cannot handleRequires 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 requiredCannot tell you which category is responsible for a significant result — only that a difference exists
Applicable to many real-world scenarios: genetics, surveys, quality controlSensitive to sample size: very large samples may flag trivial differences as significant
Makes minimal assumptions about the underlying distribution of the dataData must be raw frequencies (counts), not percentages, means, or ranks
Well-understood with widely available critical value tablesObservations must be independent — paired or repeated-measures data violates this assumption
⚠️ COMMON EXAM MISTAKE
Many students lose marks by writing 'accept H₀' instead of 'do not reject H₀.' In statistics, we never prove the null hypothesis is true — we only fail to find sufficient evidence against it. Think of it like a court trial: the verdict is 'not guilty,' not 'innocent.' The absence of evidence is not the same as evidence of absence.

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.

Comparing the goodness-of-fit test with the test of independence
FeatureGoodness-of-Fit Test (AHL 4.10)Test of Independence (Extension)
PurposeTests whether data fits a specific theoretical distributionTests whether two categorical variables are associated
Data layoutOne row of observed vs. expected frequenciesTwo-way contingency table (r × c)
Degrees of freedomν = k − 1ν = (r − 1)(c − 1)
Expected frequency formulafₑ = n × pᵢfₑ = (row total × column total) / grand total
H₀Data follows the specified distributionThe 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.

📝 IB Exam Connection
On the IB exam, chi-squared questions often appear in Paper 2 or Paper 3 and may combine with probability distributions or expected value calculations. Be prepared to: (1) set up hypotheses, (2) calculate expected frequencies, (3) use your GDC to find χ²calc and the p-value, and (4) write a clear conclusion in context.

Practice Problems

PROBLEM 1CONCEPTUAL
Explain why the chi-squared test is always right-tailed (one-tailed). What would a very small χ² value tell you about your data compared to the expected values?
PROBLEM 2BASIC CALCULATION
A spinner has four equal sections: A, B, C, D. A student spins it 80 times and records: A = 25, B = 15, C = 22, D = 18. Calculate χ²calc and determine whether the spinner is fair at the 5% significance level.
PROBLEM 3INTERMEDIATE
A genetics experiment predicts offspring phenotypes in a 9:3:3:1 ratio. Out of 320 offspring, the observed counts are: 185 (Type A), 60 (Type B), 52 (Type C), 23 (Type D). Test at the 1% significance level whether the observed data fits the predicted genetic ratio.
PROBLEM 4APPLIED
A marketing team surveyed 500 customers about their preferred social media platform. They predicted: Instagram 40%, TikTok 25%, YouTube 20%, Other 15%. The survey yielded: Instagram 220, TikTok 110, YouTube 95, Other 75. At the 5% level, does the survey data support their prediction? If H₀ is rejected, identify which category contributed most to the χ² value and discuss what this might mean for the marketing team.
PROBLEM 5CRITICAL THINKING
A teacher rolls a die 600 times and gets each face exactly 100 times, yielding χ²calc = 0. Another teacher rolls a different die 12 times and records 2 of each face, also getting χ²calc = 0. Both conclude that their die is perfectly fair. Critically evaluate both conclusions. Which conclusion is more reliable, and why? Discuss the role of sample size, and explain what conditions might make you suspicious of a χ²calc = 0 result.

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₀.'

Varsity Tutors • IB Mathematics: Analysis and Approaches • Chi-Squared Distribution — AHL 4.10