You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
The chi-squared (χ2) goodness-of-fit test answers a question that runs through all of applied statistics: does my data actually follow the model I assumed? You have a set of observed frequencies and a candidate distribution — uniform, binomial, Poisson, normal — that predicts expected frequencies. The test measures the total discrepancy with a single statistic and compares it against the χ2 distribution. This lesson covers the full method with correct degrees-of-freedom bookkeeping, the all-important class-pooling rule, and three fully-worked tests with mark schemes.
This is Paper 3 Statistics option (7367/3S) content (per-paper weighting AO1 40% / AO2 25% / AO3 35%) — the first of two hypothesis-testing lessons (Lesson 10 covers contingency tables). Computing expected frequencies and the test statistic is AO1; the reasoning — choosing the degrees of freedom, deciding when to pool classes, and writing a conclusion in context — is heavily AO2/AO3. The prerequisites are the Poisson and binomial distributions (Lessons 2–3) for generating expected frequencies, and the general logic of hypothesis testing (null/alternative, significance level, critical value) from A-Level Mathematics.
If the model is correct, observed frequencies Oi should sit close to the expected frequencies Ei; large gaps are evidence against the model. The test statistic measures the total relative gap:
X2=∑iEi(Oi−Ei)2.
Squaring makes every term non-negative (so over- and under-estimates do not cancel); dividing by Ei weights each gap relative to what was expected (a gap of 5 matters more where 10 was expected than where 100 was). Under H0, X2 is approximately distributed as chi-squared with ν degrees of freedom, written χν2. The test is one-tailed (upper): only a large X2 discredits the model.
It is worth pausing on why the statistic takes this particular form. Each term Ei(Oi−Ei)2 is, to a good approximation, a squared standardised residual: if the count in class i behaves like a Poisson (or binomial) variable with mean Ei, its standard deviation is roughly Ei, so EiOi−Ei is a standardised quantity and its square is Ei(Oi−Ei)2. Summing k such squared standardised residuals gives, under H0, something close to a sum of squared standard normals — and a sum of squared independent standard normals is exactly a chi-squared variable. This is the intuition behind the reference distribution, and it also explains the Ei≥5 rule: the normal approximation to each count is poor when the expected frequency is small, so the chi-squared approximation to the sum breaks down unless the expected frequencies are reasonably large. Understanding this makes the otherwise mysterious pooling rule feel inevitable rather than arbitrary.
ν=(number of classes used)−1−(number of parameters estimated from the data)
The "−1" is the constraint that ∑Ei=∑Oi=n (the totals are forced to match). Each parameter you estimate from the sample (rather than being told) costs a further degree of freedom.
| Model being tested | Parameters estimated | ν (with k classes) |
|---|---|---|
| Uniform / given distribution | 0 | k−1 |
| Poisson, λ given | 0 | k−1 |
| Poisson, λ estimated by xˉ | 1 | k−2 |
| Binomial, p given | 0 | k−1 |
| Binomial, p estimated | 1 | k−2 |
| Normal, μ and σ2 estimated | 2 | k−3 |
⚠️ Count k after any pooling (next), and remember an estimated parameter only counts if you estimated it from this data set.
The chi-squared approximation is unreliable when an expected frequency is small. The standard A-Level rule is: every Ei must be at least 5; if any Ei<5, combine it with an adjacent class (and add the corresponding observed frequencies) until all pooled expected frequencies reach 5. Then recount k for the degrees of freedom.
A die is rolled 120 times:
| Face | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| Observed O | 15 | 23 | 18 | 25 | 17 | 22 |
H0: the die is fair (each face has probability 61). H1: the die is not fair. Expected E=6120=20 per face (B1; all E≥5, no pooling).
| Face | O | E | (O−E)2/E |
|---|---|---|---|
| 1 | 15 | 20 | 25/20=1.25 |
| 2 | 23 | 20 | 9/20=0.45 |
| 3 | 18 | 20 | 4/20=0.20 |
| 4 | 25 | 20 | 25/20=1.25 |
| 5 | 17 | 20 | 9/20=0.45 |
| 6 | 22 | 20 | 4/20=0.20 |
X2=1.25+0.45+0.20+1.25+0.45+0.20=3.80.(M1 ∑(O−E)2/E; A1 3.80)
Degrees of freedom ν=6−1=5 (B1). At the 5% level the critical value is χ52=11.07. Since 3.80<11.07 we do not reject H0 (M1 compare; A1 conclusion): there is no significant evidence at the 5% level that the die is unfair.
Accidents per day at a junction over 100 days:
| Accidents | 0 | 1 | 2 | 3 | 4 | 5+ |
|---|---|---|---|---|---|---|
| Days O | 30 | 36 | 20 | 8 | 4 | 2 |
H0: the data follow a Poisson distribution; H1: they do not.
Estimate λ by the sample mean:
xˉ=1000(30)+1(36)+2(20)+3(8)+4(4)+5(2)=1000+36+40+24+16+10=100126=1.26.(B1)
Expected frequencies from Po(1.26) (using P(r)=rλP(r−1)):
| r | P(X=r) | E=100P |
|---|---|---|
| 0 | e−1.26=0.2837 | 28.37 |
| 1 | 1.26×0.2837=0.3575 | 35.75 |
| 2 | 21.26×0.3575=0.2252 | 22.52 |
| 3 | 31.26×0.2252=0.0946 | 9.46 |
| ≥4 | 1−0.9610=0.0390 | 3.90 |
The class ≥4 has E=3.90<5, so pool it with class 3: pooled E=9.46+3.90=13.36, pooled O=8+(4+2)=14 (M1 pooling shown). This leaves k=4 classes: {0,1,2,≥3}.
| Class | O | E | (O−E)2/E |
|---|---|---|---|
| 0 | 30 | 28.37 | 2.6569/28.37=0.0936 |
| 1 | 36 | 35.75 | 0.0625/35.75=0.0017 |
| 2 | 20 | 22.52 | 6.3504/22.52=0.2820 |
| ≥3 | 14 | 13.36 | 0.4096/13.36=0.0307 |
X2=0.0936+0.0017+0.2820+0.0307=0.408.(M1 A1)
Degrees of freedom: k=4 classes, 1 parameter estimated (λ), so ν=4−1−1=2 (B1). At 5%, χ22=5.991. Since 0.408<5.991, do not reject H0 (A1): the data are consistent with a Poisson model.
Exam Tip: Pool first, then count classes for ν. Here pooling reduced six raw classes to four, and estimating λ removed one more degree of freedom — both steps are common mark-losers if skipped.
A coin is tossed 100 times, giving 60 heads and 40 tails. Test at 5% whether the coin is fair.
H0: p(head)=0.5; H1: p=0.5. Expected: 50 heads, 50 tails. Here k=2 and ν=2−1=1, so apply Yates' continuity correction:
X2=∑E(∣O−E∣−0.5)2=50(10−0.5)2+50(10−0.5)2=5090.25+5090.25=1.805+1.805=3.61.(M1 A1)
At 5%, χ12=3.841. Since 3.61<3.841, do not reject H0 (A1): no significant evidence the coin is biased. (Without Yates' correction X2=4.00>3.841 would reject — showing why the correction matters when ν=1.)
(Specimen-style — not from any real paper.)
A biologist counts the number of seeds germinating in each of 80 trays of 4 seeds, and proposes a B(4,0.5) model.
| Germinating | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
| Trays O | 6 | 18 | 28 | 20 | 8 |
Test at the 5% level whether B(4,0.5) fits.
Solution. H0: the data follow B(4,0.5); H1: they do not. The B(4,0.5) probabilities are 161,164,166,164,161, so with n=80:
| r | P | E=80P | O | (O−E)2/E |
|---|---|---|---|---|
| 0 | 1/16 | 5 | 6 | 1/5=0.20 |
| 1 | 4/16 | 20 | 18 | 4/20=0.20 |
| 2 | 6/16 | 30 | 28 | 4/30=0.1333 |
| 3 | 4/16 | 20 | 20 | 0/20=0 |
| 4 | 1/16 | 5 | 8 | 9/5=1.80 |
All E≥5, so no pooling. X2=0.20+0.20+0.1333+0+1.80=2.333. Here p was given (not estimated), so ν=5−1=4; at 5%, χ42=9.488. Since 2.333<9.488, do not reject H0: B(4,0.5) is an adequate model at the 5% level.
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.