Menu
Sign up Sign in

AI HL · 13.4

Hypothesis Testing

13.4.3

Testing the fit of a model

13.4.3

Testing the fit of a model

Target: I can find expected frequencies from a normal model, with open-ended first and last groups. (+4 more)

By the end of this section

Key points

Expected frequencies from a model

  • Find the probability of each group from the model, then multiply by the sample size n: E = n × P.
  • Normal model: the first group is \(P(X < a)\) and the last is \(P(X \geq b)\). They have no lower or upper limit, so the probabilities add up to 1.
  • Binomial model: X is the number of successes in one set of trials. Six fair coins give \(X \sim B(6, 0.5)\). The number of repeats of the set is the sample size.
  • A probability function given as a formula: substitute each value of x. Check that the probabilities add up to 1.
  • The expected frequencies must add up to n. Each should be at least 5.

The test

  • \(H_0\): the data follow the model, named in full, for example \(N(70, 8^2)\) or \(B(4, 0.6)\). \(H_1\): they do not.
  • df = number of groups − 1. The model's values are given, not estimated from the data.
  • Find \(\chi^2\) and p on the calculator from the observed and expected lists.
  • If \(p < \alpha\), or \(\chi^2\) is bigger than the critical value, reject \(H_0\). Otherwise there is insufficient evidence to reject it.

Writing the conclusion

  • State the significance level and compare it with p, for example "0.0713 < 0.1".
  • Write the decision in context: "sufficient evidence that the scores do not follow \(N(70, 8^2)\)".
  • Never say the model is proved. "Do not reject \(H_0\)" means the data are consistent with the model.

On the calculator

Probabilities from a normal model

  • Use the normal cumulative distribution with the mean and standard deviation of the model.
  • For an open-ended group enter a very large limit, or use \(1 -\) the cumulative probability.
  • Multiply each probability by n to get the expected frequency.

Screenshot and video to come

Probabilities from a binomial model

  • Use the binomial probability for each value of X with the model's n and p.
  • Multiply each probability by the number of repeats to get the expected frequency.

Screenshot and video to come

The χ² goodness of fit test

  • Enter the observed and expected frequencies in two lists.
  • Enter the degrees of freedom: groups − 1.
  • Read χ² and the p-value.

Screenshot and video to come

Explore: does the data fit the model?

Compare the observed counts with the counts the model expects. Drag the orange point on top of a bar, or type a count, and see what χ² and the conclusion say.

ObservedProportionExpectedAdds to χ²

Press a name in the table to see its expected count worked out. Bars are the observed counts, teal lines the expected counts.

χ² (add the contributions)
Degrees of freedom
p-value

Drag a bar to start.

  1. In "A die", the 6 is far above its expected count. Lower it a little at a time. How low must it go before H₀ is no longer rejected?
  2. In "Days of the week", the result changes between the 5% and the 10% levels. What is the p-value, and why does the level matter?
  3. Make every observed count equal to its expected count. What are χ² and the p-value? What if the counts fit almost perfectly?
  4. Why are the degrees of freedom one less than the number of groups?

Worked examples

Problems like the ones in class. Pick one, try it, then open the working.
A normal model

The scores of 150 students in a fitness test are grouped as shown. A teacher claims that the scores follow the normal distribution \(N(70, 8^2)\). Test the claim at the 5% significance level.

ScoreBelow 5858 to 6666 to 7474 to 8282 or moreFrequency1430623410
Working
  1. Hypotheses

    \(H_0\): the scores follow \(N(70, 8^2)\). \(H_1\): they do not.

    Name the model in full.

  2. Probabilities

    From the calculator: P(X < 58) = 0.0668, P(58 < X < 66) = 0.242, P(66 < X < 74) = 0.383, P(74 < X < 82) = 0.242, P(X > 82) = 0.0668

    The first and last groups are open-ended. Together the five probabilities make 1.

  3. Expected

    E = 150 × P = 10.0, 36.3, 57.4, 36.3, 10.0

    All are at least 5. They add up to 150.

  4. Test

    df = 5 − 1 = 4. From the calculator: χ² = 3.16, p = 0.531

    Observed list and expected list, df = 4.

  5. Conclude

    0.531 > 0.05, so do not reject \(H_0\). Insufficient evidence, at the 5% level, that the scores do not follow \(N(70, 8^2)\).

    The data are consistent with the teacher's claim.

Video walkthrough coming
A binomial model

A basketball player scores with each free throw with probability 0.6, independently. She takes 4 throws in a set and does 250 sets. Let X be the number of throws scored in a set. State the distribution of X and find the expected frequency of sets in which she scores exactly 2.

Working
  1. The model

    \(X \sim B(4, 0.6)\)

    4 throws, each scores with probability 0.6. The 250 sets are the sample size.

  2. Probabilities

    From the calculator: P(X = 0, 1, 2, 3, 4) = 0.0256, 0.1536, 0.3456, 0.3456, 0.1296

    One probability for each value from 0 to 4.

  3. Expected

    E = 250 × P = 6.4, 38.4, 86.4, 86.4, 32.4

    For X = 2: 250 × 0.3456 = 86.4. The five values add up to 250.

Video walkthrough coming
A model given as a formula

In a game a player's score X is 1, 2, 3, 4 or 5, and a game designer models it by \(P(X = x) = \frac{x(6 - x)}{35}\). In 140 plays the scores are expected to follow this model. Find the expected frequency of a score of 3.

Working
  1. Probabilities

    P(X = x) = 5/35, 8/35, 9/35, 8/35, 5/35

    Put x = 1, 2, 3, 4, 5 into the formula. They add up to 35/35 = 1.

  2. Expected

    E = 140 × P = 20, 32, 36, 32, 20

    For x = 3: 140 × 9/35 = 36.

Video walkthrough coming
Using a critical value

In the game above the 140 plays gave scores 1 to 5 with frequencies 24, 28, 41, 29, 18. The expected frequencies are 20, 32, 36, 32, 20. Test the model at the 5% level. The critical value of \(\chi^2\) with df = 4 at the 5% level is 9.488.

Working
  1. Hypotheses

    \(H_0\): the scores follow \(P(X = x) = x(6-x)/35\). \(H_1\): they do not.

    Name the model.

  2. Calculator

    df = 4. From the calculator: χ² = 2.48, p = 0.649

    Five groups, so df = 4.

  3. Compare

    2.48 < 9.488

    χ² is smaller than the critical value.

  4. Conclude

    Do not reject \(H_0\). Insufficient evidence, at the 5% level, that the scores do not follow the designer's model.

    The model fits the 140 plays well enough.

Video walkthrough coming
Is a die fair?

A six-sided die is rolled 180 times. The faces 1 to 6 come up 22, 31, 29, 25, 50 and 23 times. Test at the 2% significance level whether the die is fair.

Face123456Observed223129255023
Working
  1. Hypotheses

    \(H_0\): the die is fair. \(H_1\): the die is not fair.

    A fair die has probability 1/6 for each face.

  2. Expected

    E = 180 ÷ 6 = 30 for each face; df = 5

    Six groups, so df = 5.

  3. Calculator

    From the calculator: χ² = 18, p = 0.00295

    Use the 2% level the question gives.

  4. Compare

    p = 0.00295 < 0.02

    p is below the significance level.

  5. Conclude

    Reject \(H_0\). There is sufficient evidence, at the 2% level, that the die is not fair.

    The 5 came up 50 times, far more than 30, and gives most of the χ².

Video walkthrough coming
Is the player's model right?

The basketball player's 250 sets gave 0, 1, 2, 3, 4 throws scored with frequencies 5, 36, 92, 81, 36. Test at the 5% level whether the number of throws scored in a set follows \(B(4, 0.6)\).

Throws scored01234Observed536928136Expected6.438.486.486.432.4
Working
  1. Hypotheses

    \(H_0\): the number scored follows \(B(4, 0.6)\). \(H_1\): it does not.

    Name the binomial model in full.

  2. Expected

    E = 6.4, 38.4, 86.4, 86.4, 32.4; df = 5 − 1 = 4

    From the previous example. All are at least 5.

  3. Calculator

    From the calculator: χ² = 1.56, p = 0.817

    Observed list and expected list.

  4. Conclude

    0.817 > 0.05, so do not reject \(H_0\). Insufficient evidence, at the 5% level, that the number scored does not follow \(B(4, 0.6)\).

    The data are consistent with a 0.6 scoring rate.

Video walkthrough coming