The chi-squared (χ²) test is one of the most widely used statistical tests in science. It lets us compare observed frequencies with expected frequencies to determine whether there is statistically significant evidence against a null hypothesis. Whether testing whether a die is fair, whether a sample follows a Poisson distribution, or whether two categorical variables are associated, the χ² test provides a unified framework.
χ² = Σ (O − E)² / E · df = k − 1 (goodness of fit) · df = (r−1)(c−1) (contingency)
This module covers goodness-of-fit tests for uniform, binomial, and Poisson distributions, as well as contingency table tests of association — all assessed in Cambridge 9709 Statistics 2.
Learning Objectives
Calculate the χ² test statistic from observed and expected frequencies
Identify and calculate expected frequencies for uniform, binomial, and Poisson distributions
Combine cells to ensure all expected frequencies are at least 5
Determine correct degrees of freedom for goodness-of-fit tests
Set up and interpret contingency tables; calculate E_ij
Determine degrees of freedom for contingency table tests
State correct hypotheses and conclusions in context
Use critical values from χ² tables to make decisions
Understand the effect of estimating parameters on degrees of freedom
Appreciate limitations of the χ² test and when it applies
Topics in This Module
χ² Distribution
Properties, shape, degrees of freedom
Goodness of Fit
Testing if data follows a named distribution
Specific Distributions
Uniform, binomial, Poisson expected frequencies
Contingency Tables
Test of association between two variables
Combining Cells
When E < 5, merge adjacent cells
Exam Technique
Hypotheses, critical values, conclusions
The χ² Distribution
The chi-squared statistic measures how far observed frequencies deviate from expected frequencies. It is always non-negative and follows a chi-squared distribution with ν degrees of freedom.
χ² = Σ (O − E)² / E
where O = observed frequency, E = expected frequency for each category. Sum over all categories.
Properties
χ² ≥ 0 always (it is a sum of squared terms)
Shape depends on ν (degrees of freedom): heavily right-skewed for small ν, approaching normal for large ν
Mean = ν, Variance = 2ν
We always use a right-tail test: a large χ² value gives evidence against H₀
Why right-tail? When H₀ is true, O ≈ E so χ² ≈ 0. Large χ² means the data is far from what H₀ predicts — this is evidence against H₀. We only reject for large values.
Critical Values (commonly used)
ν
5% critical value
1% critical value
1
3.841
6.635
2
5.991
9.210
3
7.815
11.345
4
9.488
13.277
5
11.071
15.086
6
12.592
16.812
10
18.307
23.209
Tip: In exams, critical values are given in the question or in the provided statistical tables. You don't need to memorise them.
Worked Example 1
Computing χ² from a table
A bag contains balls. 60 are drawn with replacement. Observed: Red 18, Blue 24, Green 18. Expected (equal probability): 20, 20, 20.
χ² = (18−20)²/20 + (24−20)²/20 + (18−20)²/20 M1
= 4/20 + 16/20 + 4/20 = 0.2 + 0.8 + 0.2 = 1.2 A1
With df = 3−1 = 2, χ²_crit at 5% = 5.991. Since 1.2 < 5.991, do not reject H₀. A1
Worked Example 2
Identifying the test is right-tailed
A researcher calculates χ² = 8.42 with df = 3. Is there evidence of departure from the expected distribution at 5% significance?
χ²_crit (ν=3, 5%) = 7.815 B1
Since 8.42 > 7.815, we reject H₀. There is evidence at the 5% level that the distribution does not fit. A1
Goodness of Fit Test
A goodness-of-fit test checks whether a set of observed frequencies follows a particular distribution. The null hypothesis H₀ specifies the distribution; H₁ says it does not fit.
Full Test Procedure
Step 1: State H₀: data follows [distribution X]; H₁: data does not follow [distribution X] Step 2: State significance level (e.g. 5%) Step 3: Calculate expected frequencies E for each category using the distribution Step 4: Check all E ≥ 5. If not, combine adjacent cells (and reduce k by 1 for each merge) Step 5: Calculate χ² = Σ(O−E)²/E Step 6: Find df = k − 1 (where k = number of cells after combining) Step 7: Find χ²_crit from tables Step 8: State conclusion: if χ² > χ²_crit, reject H₀; otherwise do not reject
Combining cells: When any expected frequency E < 5, combine that cell with an adjacent cell. Each merge reduces k by 1 and df by 1. Always check after combining that all new E ≥ 5.
Conclusion wording
Reject: "There is sufficient evidence at the X% significance level to reject H₀. The data does not fit [distribution]."
Do not reject: "There is insufficient evidence to reject H₀. The data is consistent with [distribution]."
Never write "proves" — always say "evidence".
Worked Example
Goodness of fit — uniform distribution
A 6-sided die is rolled 120 times. Observed frequencies: 1→24, 2→18, 3→22, 4→17, 5→21, 6→18. Test at 5% whether the die is fair.
H₀: die is fair (each face equally likely, p = 1/6); H₁: die is not fair B1
E = 120 × 1/6 = 20 for each face. All E = 20 ≥ 5 ✓ M1
1.9 < 11.071: Do not reject H₀. The data is consistent with a fair die. A1
Testing Specific Distributions
Uniform Distribution
If X ~ Uniform over k categories with n total observations: E = n/k for every category.
E = n / k (uniform)
Binomial Distribution B(n, p)
If X ~ B(n, p) with known p and N total observations: E_r = N × P(X = r) = N × C(n,r) × p^r × (1−p)^(n−r)
E_r = N × C(n,r) × p^r × (1−p)^(n−r)
Known p: df = k − 1 (where k = cells after combining). If p is estimated from data, df = k − 2 (one additional df lost).
Poisson Distribution Po(λ)
If X ~ Po(λ) and N total observations: E_r = N × e^(−λ) × λ^r / r!
E_r = N × e^(−λ) × λ^r / r!
Estimating λ: If λ is estimated from the data using x̄, this costs 1 degree of freedom: df = k − 1 − 1 = k − 2. Always state whether parameters were estimated.
Worked Example — Poisson
Testing for Poisson fit
Cars arrive at a toll booth. In 200 one-minute intervals, the counts were: 0 cars→38, 1→72, 2→60, 3→22, 4→8. The mean is calculated as x̄ = (0×38+1×72+2×60+3×22+4×8)/200 = 256/200 = 1.28. Test at 5% if data follows Po(1.28).
H₀: data follows Po(1.28); H₁: does not. λ estimated from data so df = k − 2. B1
10.505 > 7.815: Reject H₀. Evidence data does not follow Po(1.28). A1
Contingency Tables
A contingency table shows the frequency of observations cross-classified by two categorical variables. We use a χ² test to test whether the two variables are independent (no association).
H₀: no association between [variable A] and [variable B] H₁: there is an association
Expected Frequencies
For a cell in row i, column j:
E_ij = (Row i total × Column j total) / Grand total
Degrees of Freedom
df = (number of rows − 1) × (number of columns − 1)
For a 2×3 table: df = (2−1)(3−1) = 2. For a 3×3 table: df = 4.
If any E_ij < 5, combine the corresponding row or column with an adjacent one. This changes the table dimensions and hence df.
Worked Example
2×3 Contingency Table Test
200 students classified by grade (Pass/Fail) and study method (A/B/C):
Method A
Method B
Method C
Total
Pass
40
50
30
120
Fail
20
30
30
80
Total
60
80
60
200
H₀: no association between grade and study method; H₁: there is association B1
E(Pass, A) = 120×60/200 = 36; E(Pass, B) = 120×80/200 = 48; E(Pass, C) = 120×60/200 = 36 M1
E(Fail, A) = 80×60/200 = 24; E(Fail, B) = 80×80/200 = 32; E(Fail, C) = 80×60/200 = 24 A1
All E ≥ 5 ✓. χ² = (40−36)²/36 + (50−48)²/48 + (30−36)²/36 + (20−24)²/24 + (30−32)²/32 + (30−24)²/24 M1
3.819 < 5.991: Do not reject H₀. No evidence of association between grade and study method. A1
Exam Technique
Full Hypothesis Test Layout
1. Hypotheses (in context, not just symbols):
H₀: [data follows distribution X / no association between A and B]
H₁: [data does not follow / there is association]
2. Significance level: e.g. 5%
3. Expected frequencies: Show calculations. Check all E ≥ 5 and state this.
4. χ² statistic: Show full Σ(O−E)²/E calculation. State the value.
5. Degrees of freedom: State df and the critical value from tables.
6. Conclusion: Compare χ² to χ²_crit. State decision and interpret in context.
Common Wording Pitfalls
❌ "The test proves the die is fair." → ✓ "There is no significant evidence that the die is unfair."
❌ "We accept H₀." → ✓ "We do not reject H₀." (H₀ is never proven, only not refuted)
❌ "χ² is too small to reject." → ✓ "χ² = X.XX < χ²_crit = Y.YY, so do not reject H₀."
Checklist for Full Marks
State H₀ and H₁ clearly in words (not just symbols)
Calculate all expected frequencies and verify all E ≥ 5
Combine cells if needed and state the new df
Show the full χ² computation (not just the final answer)
State df and the critical value used
State conclusion with reference to H₀ and the context
Never say "proves" — use "evidence" language
Degrees of freedom summary:
Goodness of fit, no estimated params: df = k − 1
Goodness of fit, p estimated: df = k − 2
Goodness of fit, λ estimated: df = k − 2
Contingency r×c table: df = (r−1)(c−1)
Worked Examples
Example 1 — Computing χ² by hand
O = {15, 25, 10, 30, 20}, E = {20, 20, 20, 20, 20}. Compute χ².
df = (2−1)(2−1) = 1; χ²_crit = 3.841. 1.010 < 3.841: Do not reject H₀. No association. A1
Example 7 — 3×3 Contingency, reject H₀
χ² = 14.2 computed for a 3×3 table. Test at 1%.
df = (3−1)(3−1) = 4. χ²_crit (4, 1%) = 13.277. B1
14.2 > 13.277: Reject H₀ at the 1% level. There is strong evidence of association. A1
Example 8 — Choosing the right df with estimated parameter
A Poisson model with λ estimated from data. After combining cells, k = 5 cells remain. What is df?
df = k − 1 − (number of estimated parameters) = 5 − 1 − 1 = 3 B1 A1
The 1 is subtracted because λ was estimated from the data. B1
Common Mistakes
1. Using the wrong formula
❌ χ² = Σ(O−E)/E or Σ|O−E|/E
✓ χ² = Σ(O−E)²/E — must square the difference in numerator
2. Not combining small cells
❌ Including a cell with E = 2 in the calculation
✓ Combine adjacent cells until all E ≥ 5, then recalculate df
3. Wrong degrees of freedom
❌ df = k (number of categories, forgetting to subtract 1)
✓ df = k − 1 for goodness of fit; df = (r−1)(c−1) for contingency
4. Forgetting to subtract for estimated parameters
❌ df = k − 1 when λ was estimated from data
✓ df = k − 2 when one parameter (like λ or p) was estimated from the data
5. Two-tailed conclusion
❌ "Reject H₀ because χ² is too small" or using a two-tailed critical value
✓ χ² test is always right-tailed: only reject for large χ². A small χ² means the fit is good.
6. Saying "proves"
❌ "This proves the data follows a Poisson distribution."
✓ "There is insufficient evidence to reject the Poisson model." Hypothesis tests never prove H₀.
7. Incorrect contingency E_ij formula
❌ E_ij = (row total + column total) / grand total
✓ E_ij = (row i total × column j total) / grand total — it's multiplication, not addition
Key Formulas
Formula / Rule
Description
χ² = Σ(O−E)²/E
Test statistic (sum over all cells)
E = n × P(category)
Expected frequency (general)
E = n/k
Uniform distribution (k equal categories)
E_r = N × C(n,r) × p^r × (1−p)^(n−r)
Binomial B(n,p) expected frequency
E_r = N × e^(−λ) × λ^r / r!
Poisson Po(λ) expected frequency
E_ij = R_i × C_j / n
Contingency table expected frequency
df = k − 1
Goodness of fit, no estimated parameters
df = k − 1 − p
Goodness of fit, p parameters estimated
df = (r−1)(c−1)
Contingency table (r rows, c columns)
Rule: all E ≥ 5
Combine cells if violated
χ²_crit (ν=1, 5%) = 3.841
Critical value
χ²_crit (ν=2, 5%) = 5.991
Critical value
χ²_crit (ν=3, 5%) = 7.815
Critical value
χ²_crit (ν=4, 5%) = 9.488
Critical value
χ²_crit (ν=5, 5%) = 11.071
Critical value
χ²_crit (ν=1, 1%) = 6.635
Critical value
χ²_crit (ν=3, 1%) = 11.345
Critical value
Proof Bank
1. Why df = k − 1 for goodness of fit
We have k categories. The expected frequencies E₁, E₂, …, E_k must satisfy the constraint Σ E_i = n (the total must equal the sample size). This gives one linear constraint on the k expected values. With 1 constraint, the chi-squared distribution has k − 1 degrees of freedom.
Formally: the χ² statistic with k cells, under H₀ with known probabilities, asymptotically follows χ²(k−1). Each additional estimated parameter from the data costs a further degree of freedom, giving df = k − 1 − p for p estimated parameters.
2. Why df = (r−1)(c−1) for contingency tables
An r×c contingency table has r×c cells. The row totals (r values) and column totals (c values) are fixed — but knowing r−1 row totals determines the last, and similarly for columns. The number of "free" cells we can choose is therefore:
r×c − r − c + 1 = (r−1)(c−1)
So the asymptotic distribution of χ² under H₀ (independence) is χ²((r−1)(c−1)).
3. Intuition for the χ² statistic
For a single category with expected frequency E and observed O, the quantity (O−E)/√E is approximately standard normal N(0,1) for large E (by the Central Limit Theorem for counts). Squaring gives approximately χ²(1). Summing k independent such terms gives approximately χ²(k). But the frequencies are not all independent (they sum to n), so we lose 1 df per constraint, giving χ²(k−1).
The formula Σ(O−E)²/E is therefore a sum of squared standardised deviations from expected, measuring how far the data is from the null hypothesis prediction.
χ² Distribution Explorer
Select degrees of freedom to see the χ² PDF. Toggle critical regions and mark your test statistic.
Select ν and adjust settings to explore the χ² distribution.
Exercise 1 — Computing χ²
Exercise 2 — Degrees of Freedom
Exercise 3 — Expected Frequencies
Exercise 4 — Hypothesis Test Conclusions
Type "reject" or "do not reject" for each question.
Exercise 5 — Contingency Tables
Practice — Mixed Questions (30)
Challenge — Harder Questions (15)
Exam Style Questions
Q1 [6 marks]
A 6-sided die is suspected of being biased. It is rolled 180 times with observed frequencies: 1→28, 2→35, 3→22, 4→40, 5→30, 6→25. Test at 5% significance whether the die is fair.
H₀: die is fair (p = 1/6 each); H₁: die is not fair. [B1]
E = 180/6 = 30 for each face. All E = 30 ≥ 5. [M1]
χ² = (28−30)²/30 + (35−30)²/30 + (22−30)²/30 + (40−30)²/30 + (30−30)²/30 + (25−30)²/30 [M1]
= 4/30 + 25/30 + 64/30 + 100/30 + 0/30 + 25/30 = 218/30 = 7.267 [A1]
df = 5; χ²_crit(5, 5%) = 11.071 [B1]
7.267 < 11.071: Do not reject H₀. No significant evidence the die is biased. [A1]
Q2 [7 marks]
The number of calls received per hour at a call centre in 100 hours: 0→8, 1→22, 2→30, 3→25, 4→10, 5+→5. The mean is 2.15. Test at 5% whether a Poisson model with λ = 2.15 fits the data.
H₀: X ~ Po(2.15); H₁: does not follow Po(2.15). [B1]
E₀=100e^(−2.15)=11.65; E₁=25.05; E₂=26.93; E₃=19.27; E₄=10.35; E₅+=100−92.25=7.75 [M1 A1]
All E ≥ 5 ✓. χ² = (8−11.65)²/11.65+(22−25.05)²/25.05+(30−26.93)²/26.93+(25−19.27)²/19.27+(10−10.35)²/10.35+(5−7.75)²/7.75 [M1]
= 1.145+0.372+0.351+1.701+0.012+0.976 = 4.557 [A1]
λ estimated from data: df = 6−2 = 4. χ²_crit(4,5%) = 9.488 [B1]
4.557 < 9.488: Do not reject H₀. Data is consistent with a Poisson model. [A1]
Q3 [6 marks]
150 people are classified by age group (Young/Middle/Old) and newspaper preference (A/B/C). A contingency table gives χ² = 9.84. Degrees of freedom = 4. Test at 5% for association.
H₀: no association between age group and newspaper preference; H₁: association exists. [B1]
df = (3−1)(3−1) = 4. χ²_crit(4, 5%) = 9.488. [B1]
χ² = 9.84 > 9.488. [M1]
Reject H₀ at 5% significance. [A1]
There is significant evidence of an association between age group and newspaper preference. [A1]
Q4 [5 marks]
X ~ B(4, 0.3). In 200 observations: X=0→38, X=1→82, X=2→60, X=3→18, X=4→2. Test at 5% goodness of fit.
H₀: X ~ B(4, 0.3); H₁: does not. [B1]
E₀=200×0.2401=48.02; E₁=200×0.4116=82.32; E₂=200×0.2646=52.92; E₃=200×0.0756=15.12; E₄=200×0.0081=1.62 [M1 A1]
E₄ = 1.62 < 5: combine X=3 and X=4 → O=20, E=16.74. [M1]
χ² = (38−48.02)²/48.02 + (82−82.32)²/82.32 + (60−52.92)²/52.92 + (20−16.74)²/16.74 = 2.090+0.001+0.945+0.635 = 3.671 [A1]
df = 4−1 = 3 (p known, k=4 after combining). χ²_crit(3,5%)=7.815. 3.671<7.815: Do not reject H₀. [A1]
Q5 [4 marks]
Explain why we always use a right-tailed test for χ², and why a very small χ² value does not lead to rejection of H₀.
χ² = Σ(O−E)²/E is always ≥ 0. [B1]
A large χ² means observed frequencies are far from expected — evidence against H₀. [B1]
A small χ² means O ≈ E, so the data is consistent with H₀. We only reject for large values. [B1]
There is no left critical region — using a two-tailed test would be incorrect for χ². [B1]
Q6 [5 marks]
A 2×4 contingency table has row totals 60 and 90, and column totals 30, 40, 50, 30. Calculate all expected frequencies.
Grand total = 150. [B1]
Row 1: E = 60×30/150=12, 60×40/150=16, 60×50/150=20, 60×30/150=12 [M1 A1]
Row 2: E = 90×30/150=18, 90×40/150=24, 90×50/150=30, 90×30/150=18 [A1]
All E ≥ 5 ✓. df = (2−1)(4−1) = 3. [B1]
Q7 [4 marks]
State the degrees of freedom for each test: (a) Goodness of fit with 6 categories, λ estimated. (b) Goodness of fit with 5 categories, p known. (c) 3×4 contingency table. (d) 2×2 contingency table.
400 plants grown in 4 conditions (A,B,C,D): 90, 115, 95, 100 observed. Expected under null hypothesis: 100 each. Additionally, compare to a new hypothesis where E: 80, 120, 100, 100. For each, compute χ² and test at 5%.
Null 1 (equal): χ² = (90−100)²/100 + (115−100)²/100 + (95−100)²/100 + (100−100)²/100 = 1+2.25+0.25+0 = 3.5. df=3, crit=7.815. 3.5<7.815: Do not reject. [M1 A1]
Null 2: χ² = (90−80)²/80 + (115−120)²/120 + (95−100)²/100 + (100−100)²/100 = 1.25+0.208+0.25+0 = 1.708. df=3, crit=7.815. 1.708<7.815: Do not reject. [M1 A1]
Both models are consistent with the data at 5%. [A1 A1]
Past Paper Questions
PP1 — 9709/63/O/N/18 style [6 marks]
A random sample of 200 values of a variable X gave the following frequency distribution: X=0→26, X=1→52, X=2→72, X=3→38, X=4→12. The mean was calculated as 1.79. Test at 5% whether X follows a Poisson distribution.
H₀: X ~ Po(1.79); H₁: X does not follow a Poisson distribution. [B1]
Using λ = 1.79 (estimated): E₀=200e^{-1.79}=33.40; E₁=59.79; E₂=53.51; E₃=31.93; E₄+=200−178.63=21.37. [M1 A1]
All E ≥ 5 ✓. χ² = (26−33.40)²/33.40+(52−59.79)²/59.79+(72−53.51)²/53.51+(38−31.93)²/31.93+(12−21.37)²/21.37 [M1]
= 1.638+1.013+6.396+1.156+4.108 = 14.311 [A1]
df = 5−2 = 3 (λ estimated). χ²_crit(3, 5%) = 7.815. 14.311 > 7.815: Reject H₀. Data does not follow Poisson. [A1]
PP2 — 9709/63/M/J/19 style [5 marks]
80 students classified by gender (M/F) and whether they prefer science or arts: M-Science 22, M-Arts 18, F-Science 16, F-Arts 24. Test at 10% for association between gender and subject preference.
H₀: no association between gender and subject preference; H₁: association exists. [B1]
Totals: M=40, F=40, Sci=38, Arts=42, n=80.
E(M,Sci)=40×38/80=19; E(M,Arts)=40×42/80=21; E(F,Sci)=19; E(F,Arts)=21. [M1 A1]
χ² = (22−19)²/19+(18−21)²/21+(16−19)²/19+(24−21)²/21 = 0.474+0.429+0.474+0.429 = 1.806 [M1]
df=1. χ²_crit(1,10%)=2.706. 1.806<2.706: Do not reject H₀. No evidence of association. [A1]
PP3 — 9709/62/O/N/17 style [7 marks]
A die is suspected of being biased towards 6. It is thrown 120 times: 1→18, 2→22, 3→19, 4→20, 5→17, 6→24. (a) Compute χ². (b) Test at 5%. (c) Test at 10%.
(a) E = 20 each. χ² = (18−20)²/20+(22−20)²/20+(19−20)²/20+(20−20)²/20+(17−20)²/20+(24−20)²/20 = 4/20+4/20+1/20+0+9/20+16/20 = 34/20 = 1.70 [M1 A1]
(b) df=5. χ²_crit(5,5%)=11.071. 1.70<11.071: Do not reject H₀ at 5%. [B1 A1]
(c) χ²_crit(5,10%)=9.236. 1.70<9.236: Do not reject H₀ at 10% either. [B1 A1]
Conclusion: no significant evidence of bias at either level. [A1]
PP4 — 9709/61/M/J/20 style [6 marks]
A study records number of accidents per week over 52 weeks: 0→14, 1→22, 2→10, 3→4, 4+→2. Mean = 1.19. Test if a Poisson model fits at 5%.
H₀: X ~ Po(1.19); H₁: not Poisson. λ estimated from data. [B1]
E₀=52e^{-1.19}=16.05; E₁=19.10; E₂=11.37; E₃=4.51; E₄+=52−50.03=0.97 [M1 A1]
E₄+ = 0.97 < 5: combine with X=3 → O=6, E=5.48. [M1]
χ² = (14−16.05)²/16.05+(22−19.10)²/19.10+(10−11.37)²/11.37+(6−5.48)²/5.48 = 0.262+0.440+0.165+0.049 = 0.916 [A1]
df = 4−2 = 2 (k=4 after combining, λ estimated). χ²_crit(2,5%)=5.991. 0.916<5.991: Do not reject H₀. [A1]
PP5 — 9709/63/M/J/21 style [6 marks]
300 shoppers classified by age (Under 30, 30–60, Over 60) and payment method (Cash, Card): Under30-Cash 20, Under30-Card 60, 30-60-Cash 40, 30-60-Card 80, Over60-Cash 50, Over60-Card 50. Test for association at 5%.
H₀: no association between age group and payment method; H₁: association exists. [B1]
Row totals: U30=80, 3060=120, O60=100. Col totals: Cash=110, Card=190. n=300. [M1]
E(U30,Cash)=80×110/300=29.33; E(U30,Card)=50.67; E(3060,Cash)=44.00; E(3060,Card)=76.00; E(O60,Cash)=36.67; E(O60,Card)=63.33 [A1]
χ² = (20−29.33)²/29.33+(60−50.67)²/50.67+(40−44.00)²/44.00+(80−76.00)²/76.00+(50−36.67)²/36.67+(50−63.33)²/63.33 [M1]
= 2.971+1.719+0.364+0.211+4.839+2.803 = 12.907 [A1]
df=(3−1)(2−1)=2. χ²_crit(2,5%)=5.991. 12.907>5.991: Reject H₀. Strong evidence of association between age and payment method. [A1]