EuraStudy
Notes/Statistics/Goodness of fit
Notes · StatisticsUK · A-Levels

Goodness of fit

This topic uses the chi-squared goodness-of-fit test to judge whether a set of data is consistent with a specified probability distribution. It covers computing expected frequencies from a model, the degrees of freedom (reduced when parameters are estimated), the requirement that expected frequencies are at least 5, and carrying out and interpreting the test.

5 sections·~12 min reading time·3 competencies·Level Standard 2 · Advanced 3

T·151515 / 18
Exam profile
AO1 · Compute expected frequencies from a model and the chi-squared statisticAO2 · Adjust the degrees of freedom for estimated parametersAO3 · Test the fit of a model to data and interpret the result
Operators:testcalculatefinddetermineconcludecomment

basic level

The chi-squared goodness-of-fit test is principally full A-Level (Paper 3) content within the statistical-enquiry strand.

higher level

The full A-Level expects expected frequencies from a model, the correct degrees of freedom with estimated parameters, class combination and a contextual conclusion.

Depth

Reading depth: In depth

Text

Text size: Standard

Contents · 5 sections▾
  1. Goodness of fit
    • 01The goodness-of-fit idea◐
    • 02Expected frequencies from a specified distribution◐
    • 03Degrees of freedom and estimated parameters●
    • 04Fitting a Poisson or binomial model●
    • 05Carrying out and concluding the test●
§ 01

The goodness-of-fit idea#

●●○StandardLPPearson Edexcel 9ST0, Topic 16 (Paper 3)

Key points

A goodness-of-fit test asks whether observed frequency data are consistent with a proposed probability model — a uniform distribution for a fair die, a binomial for a number of successes, a Poisson for counts, or a normal for measurements grouped into classes. The null hypothesis H0H_0H0​ states that the data DO follow the specified distribution, and the alternative H1H_1H1​ that they do not.
The method mirrors the contingency-table test: compute the frequency EXPECTED in each class if the model were true, and compare it with the frequency OBSERVED, using the chi-squared statistic χ2=∑(O−E)2E\chi^2 = \sum \dfrac{(O - E)^2}{E}χ2=∑E(O−E)2​. A small total supports the model; a large total is evidence that the data depart from it. The test is upper-tailed, since only large discrepancies count against the fit.
The chi-squared statistic and its distribution are the same machinery as for the test of association, differing only in how the expected frequencies are obtained (from a model rather than from marginal totals) and in how the degrees of freedom are counted. Recognising the goodness-of-fit setting — one variable, a proposed distribution, a comparison of observed with model-predicted counts — is the first step.
As before, the conclusion is contextual and the test only assesses fit, not the reason for any misfit. Failing to reject H0H_0H0​ does not prove the model correct; it means the data provide no evidence against it, which is the honest, carefully worded conclusion the examination requires.
H0:data follow the specified distribution;χ2=∑(O−E)2EH_0: \text{data follow the specified distribution}; \qquad \chi^2 = \sum \frac{(O - E)^2}{E}H0​:data follow the specified distribution;χ2=∑E(O−E)2​

Goodness-of-fit hypotheses and statistic

Compare observed counts with those the model predicts; the test is upper-tailed.

Worked example

Framing a goodness-of-fit test

A die is rolled 120 times and the six face counts are recorded. State the hypotheses for testing whether the die is fair.

  1. 01Model

    A fair die gives each face probability 16\tfrac{1}{6}61​ (a discrete uniform distribution).

  2. 02Null hypothesis

    H0H_0H0​: the face counts follow a uniform distribution (the die is fair).

  3. 03Alternative

    H1H_1H1​: the counts do not follow a uniform distribution (the die is biased).

Result: H0H_0H0​: the die is fair (uniform); H1H_1H1​: the die is not fair, tested by comparing observed with expected counts.

Exam focus

  • State the hypotheses as 'the data do / do not follow the specified distribution'.
  • Recognise a goodness-of-fit setting and the upper-tailed nature of the test.

Typical mistakes

  • Interpreting a non-rejection as proof that the model is exactly correct.
  • Confusing goodness of fit (one variable, a model) with a test of association (two variables).

Active revision

State the null and alternative hypotheses for testing whether the number of calls per minute follows a Poisson distribution.

Active recall

Recall the key points — then reveal.

Sources: Pearson Edexcel Level 3 Advanced GCE in Statistics (9ST0) Specification (Pearson Edexcel)

§ 02

Expected frequencies from a specified distribution#

●●○StandardLPPearson Edexcel 9ST0, Topic 16 (Paper 3)

Observed and expected face counts

Die faces: observed vs expectedColumn chart: frequency by face, Data: Observed · 1: 15; Observed · 2: 22; Observed · 3: 23; Observed · 4: 19; Observed · 5: 25; Observed · 6: 16; Expected · 1: 20; Expected · 2: 20; Expected · 3: 20; Expected · 4: 20; Expected · 5: 20; Expected · 6: 200510152025123456152022202320192025201620frequencyfaceObservedExpected
Fig. 1Observed face counts against the uniform expected value 20 (from 120 rolls of a fair die).

Key points

The expected frequency for a class is the total number of observations multiplied by the probability the model assigns to that class, E=n×P(class)E = n \times P(\text{class})E=n×P(class). For a fully specified model such as a fair die, each face has probability 16\tfrac{1}{6}61​, so in 120 rolls each expected frequency is 120×16=20120 \times \tfrac{1}{6} = 20120×61​=20. The expected frequencies always sum to the total number of observations.
The chart below sets the observed face counts (15, 22, 23, 19, 25, 16) against the uniform expected value of 20. Some faces appear more often than expected and some less, and the goodness-of-fit test judges whether these fluctuations are within what chance would produce for a fair die, or large enough to suggest bias.
For a distribution defined by a probability function — binomial, Poisson, normal — the class probabilities come from the pmf or pdf, and the expected frequencies are nnn times those probabilities. When the model has a parameter that is not given, it must first be estimated from the data (for example the Poisson λ\lambdaλ from the sample mean), a step that affects the degrees of freedom, as the next section explains.
Every expected frequency should satisfy the condition E≥5E \geq 5E≥5; classes in the tails that fall below this are combined with neighbours until the condition holds. The observed frequencies for the combined class are added together too, and the number of classes after combining is what is used to find the degrees of freedom.
E=n×P(class);for a fair die in 120 rolls,  E=120×16=20E = n \times P(\text{class}); \qquad \text{for a fair die in 120 rolls}, \; E = 120 \times \tfrac{1}{6} = 20E=n×P(class);for a fair die in 120 rolls,E=120×61​=20

Expected frequency from a model

Multiply the total by the model probability for each class; the expected frequencies sum to nnn.

Worked example

Expected frequencies for a fair die

A die is rolled 120 times. Find the expected frequency for each face under the fair-die model and confirm the total.

  1. 01Model probability

    Each face has probability 16\tfrac{1}{6}61​ under a fair die.

  2. 02Expected frequency

    E=120×16=20E = 120 \times \tfrac{1}{6} = 20E=120×61​=20 for every face.

    E=120×16=20E = 120 \times \tfrac{1}{6} = 20E=120×61​=20
  3. 03Check

    6×20=1206 \times 20 = 1206×20=120, the total number of rolls; all E≥5E \geq 5E≥5, so no combining is needed.

Result: Each face has expected frequency 20, summing to 120, with every expected frequency above 5.

Exam focus

  • Compute expected frequencies as nnn times the model probability for each class.
  • Combine tail classes so that every expected frequency is at least 5.

Typical mistakes

  • Comparing observed counts with probabilities instead of with expected FREQUENCIES.
  • Leaving expected frequencies below 5 without combining classes.

Active revision

In 200 trials a model assigns probabilities 0.5, 0.3, 0.15, 0.05 to four categories. Find the expected frequencies and state whether any classes must be combined.

Active recall

Recall the key points — then reveal.

Sources: Pearson Edexcel Level 3 Advanced GCE in Statistics (9ST0) Specification (Pearson Edexcel)

§ 03

Degrees of freedom and estimated parameters#

●●●AdvancedLPPearson Edexcel 9ST0, Topic 16 (Paper 3)

Key points

The degrees of freedom for a goodness-of-fit test start from the number of classes after any combining, and one degree of freedom is lost because the expected frequencies are constrained to sum to the observed total. A further degree of freedom is lost for EACH parameter of the model estimated from the data. The rule is df=(number of classes)−1−(number of estimated parameters)\text{df} = (\text{number of classes}) - 1 - (\text{number of estimated parameters})df=(number of classes)−1−(number of estimated parameters).
For a fully specified model, no parameter is estimated, so df=k−1\text{df} = k - 1df=k−1 for kkk classes: the fair die with six faces has 6−1=56 - 1 = 56−1=5 degrees of freedom. Fitting a Poisson distribution and estimating its mean λ\lambdaλ from the data costs one extra degree of freedom, giving df=k−2\text{df} = k - 2df=k−2; fitting a normal and estimating both μ\muμ and σ\sigmaσ costs two, giving df=k−3\text{df} = k - 3df=k−3.
The reason parameters cost degrees of freedom is that estimating them from the data forces the model to fit better than it would with parameters fixed in advance, artificially lowering the chi-squared statistic. Reducing the degrees of freedom compensates, keeping the test honest. Getting this count right is one of the most frequently examined details of the topic.
The degrees of freedom, together with the significance level, fix the critical value from the chi-squared tables, so an error here changes the whole conclusion. A reliable habit is to write out explicitly: number of classes (after combining), minus 1, minus the number of estimated parameters — and to state each subtraction.
df=k−1−p\text{df} = k - 1 - pdf=k−1−p

Degrees of freedom for goodness of fit

kkk is the number of classes after combining; ppp is the number of parameters estimated from the data.

Worked example

Degrees of freedom with an estimated parameter

Data are grouped into 6 classes and a Poisson distribution is fitted, estimating λ\lambdaλ from the sample mean. State the degrees of freedom.

  1. 01Start from classes

    There are k=6k = 6k=6 classes.

  2. 02Subtract for the total constraint

    Lose 1 degree of freedom because the expected frequencies sum to the observed total.

  3. 03Subtract for the estimated parameter

    Estimating λ\lambdaλ costs 1 further degree of freedom, so df=6−1−1=4\text{df} = 6 - 1 - 1 = 4df=6−1−1=4.

    df=6−1−1=4\text{df} = 6 - 1 - 1 = 4df=6−1−1=4

Result: The degrees of freedom are 6−1−1=46 - 1 - 1 = 46−1−1=4.

Exam focus

  • Apply df=k−1−p\text{df} = k - 1 - pdf=k−1−p, counting the estimated parameters correctly.
  • State the number of classes used after any combining.

Typical mistakes

  • Forgetting to subtract a degree of freedom for each estimated parameter.
  • Using the number of classes before combining when counting kkk.

Active revision

A Poisson model is fitted to counts grouped into 7 classes (after combining), with λ\lambdaλ estimated from the data. State the degrees of freedom.

Active recall

Recall the key points — then reveal.

Sources: Pearson Edexcel Level 3 Advanced GCE in Statistics (9ST0) Specification (Pearson Edexcel)

§ 04

Fitting a Poisson or binomial model#

●●●AdvancedLPPearson Edexcel 9ST0, Topic 16 (Paper 3)

Key points

To test whether count data follow a Poisson distribution, first estimate λ\lambdaλ by the sample mean, then compute the model probabilities P(X=x)=e−λλxx!P(X = x) = \dfrac{e^{-\lambda}\lambda^x}{x!}P(X=x)=x!e−λλx​ for each class, and multiply by the total to obtain expected frequencies. The final class is usually of the form 'x or more' so that the probabilities sum to 1 and no observation is left out.
For example, if a Poisson with estimated mean λ=2\lambda = 2λ=2 is fitted to 50 observations, the expected frequency of zero counts is 50×e−2=50×0.1353=6.7750 \times e^{-2} = 50 \times 0.1353 = 6.7750×e−2=50×0.1353=6.77. Each class's expected frequency is found the same way, and any tail classes with expected frequency below 5 are combined before the statistic is formed.
Fitting a binomial follows the same pattern: if nnn (the number of trials per unit) is known but ppp is estimated from the data, the model probabilities (nr)pr(1−p)n−r\binom{n}{r} p^r (1 - p)^{n - r}(rn​)pr(1−p)n−r give the expected frequencies, and estimating ppp costs one degree of freedom. If both nnn and ppp are estimated, two degrees of freedom are lost.
The chi-squared statistic is then computed from the observed and model-expected frequencies exactly as before, and the degrees of freedom are k−1−pk - 1 - pk−1−p with ppp the number of estimated parameters. The care lies in the bookkeeping — estimating the parameter, forming a sensible final class, combining small expected frequencies, and counting the degrees of freedom — rather than in any new idea.
Ex=n×e−λλxx!  (Poisson),Er=n×(mr)pr(1−p)m−r  (binomial)E_x = n \times \frac{e^{-\lambda}\lambda^x}{x!} \;(\text{Poisson}), \qquad E_r = n \times \binom{m}{r} p^r (1 - p)^{m - r} \;(\text{binomial})Ex​=n×x!e−λλx​(Poisson),Er​=n×(rm​)pr(1−p)m−r(binomial)

Expected frequencies from a fitted model

Estimate the parameter, compute model probabilities, multiply by the total.

Worked example

An expected frequency from a fitted Poisson

A Poisson model with estimated mean λ=2\lambda = 2λ=2 is fitted to 50 observations. Find the expected frequency of zero events.

  1. 01Model probability

    P(X=0)=e−2=0.1353P(X = 0) = e^{-2} = 0.1353P(X=0)=e−2=0.1353.

  2. 02Expected frequency

    E0=50×0.1353=6.77E_0 = 50 \times 0.1353 = 6.77E0​=50×0.1353=6.77 (3 s.f.).

    E0=50 e−2=6.77E_0 = 50\,e^{-2} = 6.77E0​=50e−2=6.77
  3. 03Note

    6.77≥56.77 \geq 56.77≥5, so this class need not be combined.

Result: The expected frequency of zero events is 50 e−2=6.7750\,e^{-2} = 6.7750e−2=6.77 (3 s.f.).

Exam focus

  • Estimate the parameter, compute model probabilities and hence expected frequencies.
  • Form a sensible 'or more' final class and combine small expected frequencies.

Typical mistakes

  • Leaving out the 'x or more' tail so the probabilities do not sum to 1.
  • Forgetting that estimating the parameter reduces the degrees of freedom.

Active revision

A Poisson model with estimated λ=1.5\lambda = 1.5λ=1.5 is fitted to 80 observations. Find the expected frequency of exactly one event.

Active recall

Recall the key points — then reveal.

Sources: Pearson Edexcel Level 3 Advanced GCE in Statistics (9ST0) Specification (Pearson Edexcel)

§ 05

Carrying out and concluding the test#

●●●AdvancedLPPearson Edexcel 9ST0, Topic 16 (Paper 3)

Chi-squared distribution for the fit test

Function graph, chi-squared, 5 df = 0.13298*x^(3/2)*exp(-x/2)Graph of chi-squared, 5 df, roots at x = 0, maximum at (3, 0.154), y-intercept at y = 0, on the interval x from 0 to 2051015200.050.10.1511.07 (5%)chi-squared, 5dfdensitychi-squared value
Fig. 2Chi-squared distribution (5 df): reject beyond 11.070; the test statistic 4.0 lies well inside the body.

Key points

The complete test assembles the pieces: state the hypotheses, compute the expected frequencies (combining any below 5), form χ2=∑(O−E)2E\chi^2 = \sum \dfrac{(O - E)^2}{E}χ2=∑E(O−E)2​, find the degrees of freedom k−1−pk - 1 - pk−1−p, and compare with the upper-tail critical value. For the fair-die data the statistic is χ2=8020=4.0\chi^2 = \dfrac{80}{20} = 4.0χ2=2080​=4.0 with 5 degrees of freedom.
The chi-squared distribution below (5 degrees of freedom) shows the decision: the rejection region is the upper tail beyond the 5% critical value 11.070, and the test statistic 4.0 lies well inside the body of the distribution, not in the tail. There is therefore no evidence against the fair-die model.
The conclusion is stated carefully: at the 5% level there is insufficient evidence to reject the hypothesis that the die is fair, so the data are consistent with a fair die. This is NOT a claim that the die is exactly fair — a goodness-of-fit test can never prove a model true, only fail to find evidence against it.
When a test DOES reject the model, the largest cell contributions indicate where the model fits worst, which can suggest a better model — a Poisson that is rejected because the variance exceeds the mean points towards overdispersion, for instance. This diagnostic use, feeding back into the modelling stage, is exactly the iterative spirit of the statistical enquiry cycle.
χ2=8020=4.0<11.070  (5 df, 5%)⇒do not reject H0\chi^2 = \frac{80}{20} = 4.0 < 11.070 \;(\text{5 df, 5\%}) \Rightarrow \text{do not reject } H_0χ2=2080​=4.0<11.070(5 df, 5%)⇒do not reject H0​

The fair-die decision

The statistic lies inside the body of the distribution, so the data are consistent with the model.

Worked example

Completing the fair-die test

A die rolled 120 times gives observed face counts 15, 22, 23, 19, 25, 16 (each expected 20). Test at the 5% level whether the die is fair (critical value 11.070 for 5 df).

  1. 01Statistic

    χ2=25+4+9+1+25+1620=8020=4.0\chi^2 = \dfrac{25 + 4 + 9 + 1 + 25 + 16}{20} = \dfrac{80}{20} = 4.0χ2=2025+4+9+1+25+16​=2080​=4.0.

  2. 02Degrees of freedom

    k−1=6−1=5k - 1 = 6 - 1 = 5k−1=6−1=5 (no parameters estimated).

  3. 03Compare

    4.0<11.0704.0 < 11.0704.0<11.070, so the statistic is not in the rejection region.

    4.0<11.070⇒do not reject H04.0 < 11.070 \Rightarrow \text{do not reject } H_04.0<11.070⇒do not reject H0​
  4. 04Conclude

    There is insufficient evidence at the 5% level that the die is biased; the data are consistent with a fair die.

Result: χ2=4.0<11.070\chi^2 = 4.0 < 11.070χ2=4.0<11.070, so do not reject H0H_0H0​: the data are consistent with a fair die.

Exam focus

  • Assemble the full test and compare χ2\chi^2χ2 with the upper-tail critical value at the correct degrees of freedom.
  • State a careful conclusion — consistency with the model, not proof of it.

Typical mistakes

  • Concluding the model is 'proved' when the test merely fails to reject it.
  • Reading the critical value at the wrong degrees of freedom after combining classes or estimating parameters.

Active revision

A fair-die test gives χ2=4.0\chi^2 = 4.0χ2=4.0 with 5 degrees of freedom (5% critical value 11.070). Complete the test with a contextual conclusion.

Active recall

Recall the key points — then reveal.

Sources: GCE AS and A level subject content (Statistics) (Department for Education / Ofqual)

Contents

Section -- / 05

    • 01The goodness-of-fit idea◐
    • 02Expected frequencies from a specified distribution◐
    • 03Degrees of freedom and estimated parameters●
    • 04Fitting a Poisson or binomial model●
    • 05Carrying out and concluding the test●

0/5 Read

From notes into training

Goodness of fit

Reinforce this topic with matching tasks from the question bank.

~12
min
3
Competencies
Practise

References & sources

Sources

Pearson Edexcel

  • Pearson Edexcel Level 3 Advanced GCE in Statistics (9ST0) Specification

Department for Education / Ofqual

  • GCE AS and A level subject content (Statistics)

Previous topic

Contingency tables

Next topic

One and two sample non-parametric tests

EuraStudy·Notes T·15·MMXXVI

Carry on to the next topic — your learning path is kept.