χ² tests

Carry out χ² goodness-of-fit tests and contingency-table tests of independence.

More
Reading settings

Read offline with Premium

Save lessons and figures on this device with Premium.

Connect at least once every 30 days to confirm Premium. Topic checks, coaching and sync need a connection.

On this page

Reading settings

Appearance and reading tools for your lessons.

Live preview

Take a moment to read at your own pace. Choose the font and spacing that feel comfortable for you.

Pause after each idea, then explain it in your own words before moving on.

Narrower lines take effect when the screen has room.

Colour theme
Reading font
Line spacing
Reading width
Section links
Worked examples

Open example banners when a lesson starts. Hints and solutions stay closed until you open them.

Checking Premium access…

Explore Premium
Revision Mode

Hide questions, activities and worked examples to read the notes. Turn off to show the full lesson.

Checking Premium access…

Explore Premium

Enlarged diagram

Is a die fair? Do call arrivals follow a Poisson model? Is subject choice linked to school? Each question compares counts observed in categories with the counts a model predicts. The χ² test turns all the category-by-category discrepancies into one number and asks whether it is too large to be put down to chance. This lesson builds that statistic, explains where its degrees of freedom come from, and then applies it to goodness-of-fit tests and to contingency tables, including the pooling and interpretation steps that examiners look for.

Comparing observed and expected frequencies

For each category, compare the observed frequency O with the frequency E expected if the null hypothesis H₀ is true. Squaring stops positive and negative discrepancies cancelling, and dividing by E judges each discrepancy relative to its size: being 5 out when 10 was expected matters far more than being 5 out when 1000 was expected.

X² = ∑((O-E)²)/E

If H₀ is true and every expected frequency is at least 5, X² approximately follows a χ² distribution with ν degrees of freedom. Small values mean the data agree with the model; large values are evidence against it. The test is therefore always upper-tailed: reject H₀ when X² exceeds the critical value χ²ν at the chosen level, or equivalently when the p-value P(χ²ν ≥ X²) is less than the significance level.

Where a χ² statistic falls against the critical value

A right-skewed density curve starts at 0 when x = 0, peaks at about 0.154 when x = 3 and falls towards zero by x = 20. The area to the right of x = 11.07 is shaded. A vertical marker at x = 4.5, the die statistic, lies to the left of the shaded region, where the density is about 0.13.

A right-skewed density curve starts at 0 when x = 0, peaks at about 0.154 when x = 3 and falls towards zero by x = 20. The area to the right of x = 11.07 is shaded. A vertical marker at x = 4.5, the die statistic, lies to the left of the shaded region, where the density is about 0.13.A right-skewed density curve starts at 0 when x = 0, peaks at about 0.154 when x = 3 and falls towards zero by x = 20. The area to the right of x = 11.07 is shaded. A vertical marker at x = 4.5, the die statistic, lies to the left of the shaded region, where the density is about 0.13.
The χ² distribution with ν = 5 degrees of freedom. The shaded upper tail beyond 11.07 has area 0.05: values there are the 5% critical region. The die example's statistic X² = 4.5 lies well inside the acceptance region.
Open full-size graphOpen full-size graph
What to noticeThe density is drawn from sampled values joined by straight segments. The curve continues beyond x = 20 with very small density; the full tail area beyond 11.07 is 0.05.
Figure data

This table is included in print while it is open.

Figure data: Where a χ² statistic falls against the critical value
SeriesxDensity
χ² density, ν = 50.00000.000000
χ² density, ν = 50.25000.014669
χ² density, ν = 50.50000.036616
χ² density, ν = 50.75000.059364
χ² density, ν = 51.00000.080657
χ² density, ν = 51.25000.099476
χ² density, ν = 51.50000.115400
χ² density, ν = 51.75000.128333
χ² density, ν = 52.00000.138369
χ² density, ν = 52.25000.145707
χ² density, ν = 52.50000.150602
χ² density, ν = 52.75000.153332
χ² density, ν = 53.00000.154180
χ² density, ν = 53.25000.153421
χ² density, ν = 53.50000.151313
χ² density, ν = 53.75000.148093
χ² density, ν = 54.00000.143976
χ² density, ν = 54.25000.139154
χ² density, ν = 54.50000.133797
χ² density, ν = 54.75000.128050
χ² density, ν = 55.00000.122042
χ² density, ν = 55.25000.115879
χ² density, ν = 55.50000.109654
χ² density, ν = 55.75000.103441
χ² density, ν = 56.00000.097304
χ² density, ν = 56.25000.091293
χ² density, ν = 56.50000.085448
χ² density, ν = 56.75000.079800
χ² density, ν = 57.00000.074371
χ² density, ν = 57.25000.069180
χ² density, ν = 57.50000.064236
χ² density, ν = 57.75000.059546
χ² density, ν = 58.00000.055112
χ² density, ν = 58.25000.050934
χ² density, ν = 58.50000.047007
χ² density, ν = 58.75000.043327
χ² density, ν = 59.00000.039887
χ² density, ν = 59.25000.036677
χ² density, ν = 59.50000.033688
χ² density, ν = 59.75000.030911
χ² density, ν = 510.00000.028335
χ² density, ν = 510.25000.025949
χ² density, ν = 510.50000.023743
χ² density, ν = 510.75000.021705
χ² density, ν = 511.00000.019827
χ² density, ν = 511.25000.018097
χ² density, ν = 511.50000.016506
χ² density, ν = 511.75000.015044
χ² density, ν = 512.00000.013702
χ² density, ν = 512.25000.012472
χ² density, ν = 512.50000.011345
χ² density, ν = 512.75000.010314
χ² density, ν = 513.00000.009371
χ² density, ν = 513.25000.008510
χ² density, ν = 513.50000.007723
χ² density, ν = 513.75000.007006
χ² density, ν = 514.00000.006352
χ² density, ν = 514.25000.005757
χ² density, ν = 514.50000.005214
χ² density, ν = 514.75000.004721
χ² density, ν = 515.00000.004273
χ² density, ν = 515.25000.003865
χ² density, ν = 515.50000.003495
χ² density, ν = 515.75000.003160
χ² density, ν = 516.00000.002855
χ² density, ν = 516.25000.002579
χ² density, ν = 516.50000.002329
χ² density, ν = 516.75000.002102
χ² density, ν = 517.00000.001897
χ² density, ν = 517.25000.001711
χ² density, ν = 517.50000.001543
χ² density, ν = 517.75000.001391
χ² density, ν = 518.00000.001253
χ² density, ν = 518.25000.001129
χ² density, ν = 518.50000.001017
χ² density, ν = 518.75000.000916
χ² density, ν = 519.00000.000824
χ² density, ν = 519.25000.000742
χ² density, ν = 519.50000.000668
χ² density, ν = 519.75000.000600
χ² density, ν = 520.00000.000540
5% critical region, x > 11.0711.07050.019325
5% critical region, x > 11.0711.25000.018097
5% critical region, x > 11.0711.50000.016506
5% critical region, x > 11.0711.75000.015044
5% critical region, x > 11.0712.00000.013702
5% critical region, x > 11.0712.25000.012472
5% critical region, x > 11.0712.50000.011345
5% critical region, x > 11.0712.75000.010314
5% critical region, x > 11.0713.00000.009371
5% critical region, x > 11.0713.25000.008510
5% critical region, x > 11.0713.50000.007723
5% critical region, x > 11.0713.75000.007006
5% critical region, x > 11.0714.00000.006352
5% critical region, x > 11.0714.25000.005757
5% critical region, x > 11.0714.50000.005214
5% critical region, x > 11.0714.75000.004721
5% critical region, x > 11.0715.00000.004273
5% critical region, x > 11.0715.25000.003865
5% critical region, x > 11.0715.50000.003495
5% critical region, x > 11.0715.75000.003160
5% critical region, x > 11.0716.00000.002855
5% critical region, x > 11.0716.25000.002579
5% critical region, x > 11.0716.50000.002329
5% critical region, x > 11.0716.75000.002102
5% critical region, x > 11.0717.00000.001897
5% critical region, x > 11.0717.25000.001711
5% critical region, x > 11.0717.50000.001543
5% critical region, x > 11.0717.75000.001391
5% critical region, x > 11.0718.00000.001253
5% critical region, x > 11.0718.25000.001129
5% critical region, x > 11.0718.50000.001017
5% critical region, x > 11.0718.75000.000916
5% critical region, x > 11.0719.00000.000824
5% critical region, x > 11.0719.25000.000742
5% critical region, x > 11.0719.50000.000668
5% critical region, x > 11.0719.75000.000600
5% critical region, x > 11.0720.00000.000540

Degrees of freedom count free categories

ν is the number of categories whose frequencies are free to vary once the constraints are imposed. The expected frequencies are always scaled to the same total as the observed ones, which removes one degree of freedom. Each parameter estimated from the data removes another:

TestDegrees of freedom
Goodness of fit, k classes after pooling, m parameters estimated from the data
ν = k-1-m
Independence in an r × c contingency table
ν = (r-1)(c-1)

Count classes after any pooling. If an expected frequency is below 5, combine that class with a neighbour, adding both the observed and the expected frequencies, before you compute X².

Worked example 1

Is the die fair?

A die is rolled 120 times, with these results:

Score123456
Frequency152518221624

Test at the 5% level of significance whether the die is fair.

Show full solutionHide solution
  1. State the hypotheses and expected frequencies

    Method

    H₀: the die is fair. H₁: the die is not fair. Under H₀ each score has expected frequency 120 × 1/6 = 20.

    Reason

    Hypotheses are statements about the population (the die), not about this sample. All six expected frequencies are at least 5, so no pooling is needed.

    Working

    Answer

    The differences O-E are -5, 5, -2, 2, -4, 4.

  2. Compute the statistic

    Method

    Square each difference, divide by E, and add.

    Reason

    Every E is 20, so the division can be done once at the end.

    Working

    Answer

    X² = (25 + 25 + 4 + 4 + 16 + 16)/20; = 4.5.
  3. Compare and conclude in context

    Method

    ν = 6-1 = 5, and the 5% critical value is χ²₅(0.05) = 11.07.

    Reason

    Only the total constrains the expected frequencies; no parameter was estimated from the data.

    Working

    Answer

    Since 4.5 < 11.07 (equivalently, p = P(χ²₅ ≥ 4.5) ≈ 0.480 > 0.05), do not reject H₀. There is insufficient evidence at the 5% level to conclude that the die is not fair.

Fitting a model with an estimated parameter

When the model has a parameter you do not know, estimate it from the same data. That estimate makes the expected frequencies agree more closely with the observations, so it costs one degree of freedom.

Worked example 2

Do emails arrive at random?

The number of emails arriving at a help desk is recorded for 120 five-minute intervals. No interval had more than 5 emails.

Emails012345
Intervals3037291473

Test at the 5% level whether a Poisson distribution is a suitable model.

Show full solutionHide solution
  1. Estimate the mean

    Method

    H₀: the number of emails in a five-minute interval follows a Poisson distribution. H₁: it does not.

    Reason

    The hypothesis names a Poisson model but not its mean, so the sample mean estimates λ.

    Working

    Answer

    λ hat = (0(30) + 1(37) + 2(29) + 3(14) + 4(7) + 5(3))/120; = 180/120 = 1.5.
  2. Find the expected frequencies and pool

    Method

    Multiply each Poisson probability by 120. The last class must cover every value from 4 upwards.

    Reason

    The model allows 5,6,7,… emails even though none were observed above 5, so the final expected frequency uses P(X ≥ 4), not P(X = 4).

    Working

    Answer

    With X∼Po(1.5), the expected frequencies are 26.78, 40.16, 30.12, 15.06 for 0 to 3, then 5.65 for exactly 4 and 2.23 for 5 or more. The last is below 5, so combine 4 and 5 or more into one class “4 or more”, with O = 7 + 3 = 10 and E = 7.88.

    Emails0123≥ 4
    O3037291410
    E26.7840.1630.1215.067.88
  3. Test with the reduced degrees of freedom

    Method

    ν = 5-1-1 = 3: five classes after pooling, one for the total and one for λ hat.

    Reason

    Counting the six original classes, or forgetting the estimated mean, would use the wrong critical value.

    Working

    Answer

    X² = 0.388 + 0.249 + 0.042 + 0.075 + 0.572; ≈ 1.33.

    The 5% critical value is χ²₃(0.05) = 7.815. Since 1.33 < 7.815 (p ≈ 0.72), do not reject H₀. There is insufficient evidence at the 5% level to say that a Poisson model is unsuitable; the arrivals are consistent with emails arriving at random at a constant average rate.

Spot the mistake 1

A spinner tested with percentages

About 5 min

A three-colour spinner is spun 60 times and lands on red 26 times, blue 20 times and green 14 times. A student converts these to percentages, 43.3%, 33.3% and 23.3%, compares them with 33.3% each and finds X² = 6.0. As 6.0 > 5.991, the student concludes at the 5% level that the spinner is biased. Explain the error and give the correct conclusion.

Write your answer, then compare it with the solution

Show full solutionHide solution
  1. Use the actual counts

    Method

    Compare the observed counts with expected counts of 20 each.

    Reason

    The χ² approximation describes counts. Its size depends on the sample size, and percentages behave as if there were 100 observations instead of 60.

    Working

    Answer

    X² = (6² + 0² + (-6)²)/20; = 3.6.

    With ν = 3-1 = 2 the critical value is 5.991. Since 3.6 < 5.991, do not reject H₀: there is insufficient evidence at the 5% level that the spinner is biased.

Contingency tables test independence

A contingency table classifies each individual in two ways. H₀ states that the two classifications are independent. Under independence, the probability of falling in a given row and a given column is the product of the row and column proportions, so

E = (row total × column total)/(grand total).

Once the row and column totals are fixed, filling in (r-1)(c-1) cells determines the rest of the table, which is why ν = (r-1)(c-1). Pool rows or columns only when some expected frequency is below 5, and recompute the degrees of freedom for the smaller table.

Check your understanding 1

Subject preference and school

Students from two schools chose their favourite subject:

SchoolMathsScienceArtsTotal
P30201060
Q20303080
Total505040140

Test at the 5% level whether preference is independent of school.

Show answerHide answer

H₀: subject preference is independent of school. H₁: subject preference is not independent of school. The expected frequencies (row total × column total ÷ 140) are

SchoolMathsScienceArts
P21.4321.4317.14
Q28.5728.5722.86

All are at least 5. The contributions ((O-E)²)/E are 3.429, 0.095, 2.976 for school P and 2.571, 0.071, 2.232 for school Q, so X² ≈ 11.38 with ν = (2-1)(3-1) = 2.

The 5% critical value is 5.991, and 11.38 > 5.991 (p ≈ 0.003), so reject H₀. There is sufficient evidence at the 5% level that subject preference is associated with school. The largest contributions come from Maths and Arts: school P chose Maths more often, and Arts less often, than independence would predict.

Rejecting independence shows an association between the classifications. It does not show that one causes the other, and it says nothing about which school is “better”. To describe the association, point to the cells with the largest contributions and say in which direction O differs from E.

Common mistakes

  • Using percentages or proportions instead of frequencies.
  • Rounding expected frequencies to whole numbers. They are averages and are usually not integers.
  • Forgetting to pool a class with E < 5, or pooling on the observed frequencies instead of the expected ones.
  • Counting classes before pooling, or forgetting to subtract one for each parameter estimated from the data.
  • Using a two-tailed critical value. Only large values of X² count against H₀.
  • Concluding that H₀ is true, or that an association proves causation. Yates’ continuity correction is not part of this syllabus.

Before you move on

Check your understanding 2

Set up three tests

  1. A 3 × 4 contingency table is tested for independence. No pooling is needed.
  2. In a different 2 × 5 table, a cell lies in a row with total 45 and a column with total 60. The grand total is 150.
  3. Data on the number of heads in 5 coin tosses are fitted by B(5,p), with p estimated from the data. After pooling, 4 classes remain.

Show answerHide answer
  1. ν = (3-1)(4-1) = 6.
  2. E = (45 × 60)/150 = 18.
  3. ν = 4-1-1 = 2: four classes, less one for the total and one for the estimated p.

Questions

Open the discussion

Syllabus and review details

Last reviewed:

Back to top