AP-STATS-8.1-8.3

U8.1 Chi-Square Goodness of Fit

Master the chi-square goodness-of-fit test: set up hypotheses, compute expected counts, calculate χ² = Σ(O−E)²/E, find the p-value with df = k−1, and conclude in context.

What you'll do in this lesson

A voice-first session with the Crimsora tutor on U8.1 Chi-Square Goodness of Fit, then targeted practice and FRQs — with the tutor adapting to where you get stuck.

What this lesson covers

Sometimes you want to know whether a single categorical variable follows a claimed distribution. Does a bag of candy really contain the advertised color percentages? Are births evenly spread across the days of the week? The chi-square goodness-of-fit test answers exactly these questions by comparing what you actually observed to what you would expect if a claim were true.

In this lesson you will learn to state hypotheses about a distribution, check the conditions, build expected counts, compute the test statistic χ2=(OE)2E\chi^2 = \sum \frac{(O-E)^2}{E}, and read a p-value from the chi-square distribution with df=k1df = k-1. Getting the conclusion right in context is where the AP exam awards points, so we finish there.

When to Use a Goodness-of-Fit Test

A chi-square goodness-of-fit (GOF) test applies to one categorical variable with two or more categories. You have a single sample, you count how many observations fall into each category, and you compare those counts to a claimed distribution.

The hypotheses are always about proportions across categories. The null hypothesis states the claimed distribution; the alternative says the claim is wrong somewhere.

H0H_0: the categorical variable follows the specified distribution (for example, pred=0.20p_{red}=0.20, pblue=0.20p_{blue}=0.20, pgreen=0.30p_{green}=0.30, pyellow=0.30p_{yellow}=0.30).

HaH_a: at least one of the stated proportions is incorrect.

A common misconception is writing HaH_a as a single proportion being different, or using \ne symbols for each category. Instead, phrase the alternative as "at least one proportion differs from the claimed value." Never write hypotheses in terms of the observed counts; they must describe the population distribution.

Distinguish GOF from a chi-square test for two-way tables (the next lesson): GOF uses one variable and one sample, while two-way tests involve two variables or multiple groups. On the AP exam, if you see a single row of counts compared to claimed percentages, reach for goodness-of-fit.

Conditions and Expected Counts

Before computing anything, verify three conditions.
ConditionWhat to check
RandomData come from a random sample or randomized process
Independence (10%)Sample size is less than 10% of the population when sampling without replacement
Large countsEvery expected count is at least 5
The large counts condition uses expected counts, not observed counts. Compute each expected count as Ei=npiE_i = n \cdot p_i, where nn is the total sample size and pip_i is the proportion claimed under H0H_0 for that category.

For example, if n=200n = 200 and H0H_0 claims pred=0.20p_{red} = 0.20, then Ered=200×0.20=40E_{red} = 200 \times 0.20 = 40. Do this for every category; the expected counts must sum to nn, which is a useful arithmetic check.

Students often forget that expected counts do not need to be whole numbers. An expected count of 33.3333.33 is perfectly valid and should not be rounded before the calculation. Keep full precision through the computation to avoid a wrong test statistic. Also remember to explicitly state each condition on the exam, not just claim "conditions are met."

Computing the Statistic and P-Value

The test statistic measures the total relative discrepancy between observed and expected:χ2=(OE)2E\chi^2 = \sum \frac{(O-E)^2}{E}For each category, subtract expected from observed, square the difference, divide by the expected count, then add all the terms. Larger values mean observed counts are farther from what H0H_0 predicts, so large χ2\chi^2 gives evidence against the null.

The degrees of freedom for a GOF test is df=k1df = k - 1, where kk is the number of categories. Not the sample size, not k2k-2; simply one less than the number of categories.

The p-value is always the area to the right of your χ2\chi^2 value under the chi-square distribution with that df. Chi-square tests are inherently one-tailed on the right because only large discrepancies count as evidence against H0H_0. You can find this with technology (χ2\chi^2cdf with lower bound = your statistic, upper bound = large number like 109910^{99}) or a chi-square table.

A frequent error is using a two-tailed area or a normal distribution. Another is forgetting that the chi-square distribution is right-skewed and only takes non-negative values.

Concluding in Context

The conclusion follows the same logic as any significance test. Compare the p-value to the significance level α\alpha (use 0.050.05 if none is given).

If pαp \le \alpha: reject H0H_0. There is convincing evidence that the true distribution differs from the claimed distribution.

If p>αp > \alpha: fail to reject H0H_0. There is not convincing evidence that the distribution differs from the claim.

Always state the conclusion in the context of the problem, naming the variable and the claimed distribution. For instance: "Because the p-value of 0.030.03 is less than 0.050.05, we reject H0H_0; we have convincing evidence that the color distribution of candies differs from the company's stated percentages."

Two cautions the AP exam rewards. First, never "accept" H0H_0; you only fail to reject it. Second, a GOF test tells you that the distribution differs somewhere but does not identify which category is off. If asked which category contributed most, examine the individual components (OE)2E\frac{(O-E)^2}{E}; the largest term flags the category driving the result. This kind of follow-up analysis appears often on free-response questions.

Key terms

Chi-square goodness-of-fit test.
A significance test comparing observed category counts from one sample to the counts expected under a claimed distribution for one categorical variable.
Observed count (O).
The actual number of data values that fall in a category in the collected sample.
Expected count (E).
The count expected in a category if H0H_0 is true, computed as Ei=npiE_i = n \cdot p_i.
Chi-square statistic.
χ2=(OE)2E\chi^2 = \sum \frac{(O-E)^2}{E}, measuring total relative discrepancy between observed and expected counts.
Degrees of freedom.
For a GOF test, df=k1df = k - 1, where kk is the number of categories.
P-value.
The probability, assuming H0H_0 is true, of getting a χ2\chi^2 statistic at least as large as the observed one; the right-tail area.
Large counts condition.
The requirement that every expected count be at least 5 for the chi-square approximation to be valid.
Components.
The individual terms (OE)2E\frac{(O-E)^2}{E}; the largest indicates which category contributes most to the statistic.

Worked example

A gaming company claims its loot-box drops are 50% common, 30% rare, and 20% legendary. A player opens 150 boxes and records 60 common, 54 rare, and 36 legendary. Test at α=0.05\alpha = 0.05 whether the observed distribution differs from the company's claim.
State hypotheses. H0H_0: the true drop distribution is pcommon=0.50p_{common}=0.50, prare=0.30p_{rare}=0.30, plegendary=0.20p_{legendary}=0.20. HaH_a: at least one of these proportions is incorrect.

Check conditions. The 150 boxes are assumed to be a random sample of drops, and 150 is less than 10% of all possible drops. Expected counts: Ecommon=150(0.50)=75E_{common}=150(0.50)=75, Erare=150(0.30)=45E_{rare}=150(0.30)=45, Elegendary=150(0.20)=30E_{legendary}=150(0.20)=30. All are at least 5, so the large counts condition is met. (Notice 75+45+30=15075+45+30=150, matching nn.)

Compute the statistic.χ2=(6075)275+(5445)245+(3630)230\chi^2 = \frac{(60-75)^2}{75} + \frac{(54-45)^2}{45} + \frac{(36-30)^2}{30}=22575+8145+3630=3.0+1.8+1.2=6.0= \frac{225}{75} + \frac{81}{45} + \frac{36}{30} = 3.0 + 1.8 + 1.2 = 6.0Find the p-value. With df=k1=31=2df = k - 1 = 3 - 1 = 2, the right-tail area beyond χ2=6.0\chi^2 = 6.0 is approximately 0.04980.0498.

Conclude. Since p0.04980.05p \approx 0.0498 \le 0.05, we reject H0H_0. We have convincing evidence that the true loot-box drop distribution differs from the company's stated percentages. The largest component came from the common category (3.03.0), suggesting fewer common drops than claimed.

Practice questions

A researcher runs a chi-square goodness-of-fit test with 6 categories. What are the degrees of freedom?
  1. 4
  2. 5
  3. 6
  4. 36

Answer: 5

For a goodness-of-fit test, df=k1df = k - 1 where kk is the number of categories. With 6 categories, df=61=5df = 6 - 1 = 5. Degrees of freedom depend on the number of categories, not the sample size.
Which of the following is a correct reason to reject the null hypothesis in a chi-square goodness-of-fit test?
  1. The observed counts exactly equal the expected counts
  2. The p-value is greater than the significance level
  3. The chi-square statistic is large, producing a small p-value
  4. The expected counts are all below 5

Answer: The chi-square statistic is large, producing a small p-value

A large χ2\chi^2 means observed counts differ substantially from expected, giving a small right-tail p-value. When that p-value is at or below α\alpha, we reject H0H_0. Exactly equal counts would give χ2=0\chi^2 = 0 (strong agreement), and expected counts below 5 violate a condition rather than justify rejection.
A dietician claims that a mix of trail mix is 40% peanuts, 35% raisins, and 25% chocolate by count. A sample of 300 pieces contains 108 peanuts, 117 raisins, and 75 chocolate. State the hypotheses, compute the expected counts and the chi-square statistic, and describe how you would reach a conclusion at α=0.05\alpha = 0.05.

Answer: χ2=1.5\chi^2 = 1.5 with df=2df = 2; fail to reject H0H_0.

Hypotheses: H0H_0: ppeanut=0.40,praisin=0.35,pchoc=0.25p_{peanut}=0.40, p_{raisin}=0.35, p_{choc}=0.25; HaH_a: at least one proportion differs. Expected counts: 300(0.40)=120300(0.40)=120, 300(0.35)=105300(0.35)=105, 300(0.25)=75300(0.25)=75. Statistic: (108120)2120+(117105)2105+(7575)275=144120+144105+0=1.2+1.371+0=2.571\frac{(108-120)^2}{120}+\frac{(117-105)^2}{105}+\frac{(75-75)^2}{75} = \frac{144}{120}+\frac{144}{105}+0 = 1.2+1.371+0 = 2.571. With df=2df=2, the p-value is about 0.280.28, which is greater than 0.050.05, so we fail to reject H0H_0; there is not convincing evidence the trail mix distribution differs from the claim.

FAQ

What is the difference between goodness-of-fit and a chi-square test for two-way tables?
Goodness-of-fit involves one categorical variable from a single sample compared to a claimed distribution. A two-way table test (covered in a later lesson) involves counts organized by two categorical variables or multiple groups, testing independence or homogeneity. If you see one row of counts versus claimed percentages, use goodness-of-fit.
Why is the chi-square test always right-tailed?
The statistic χ2=(OE)2E\chi^2 = \sum \frac{(O-E)^2}{E} is built from squared differences, so it is always non-negative and grows only when observed counts deviate from expected. Only large values indicate a poor fit, so evidence against H0H_0 lies in the right tail. There is no meaningful left-tail rejection region.
Do expected counts have to be whole numbers?
No. Expected counts are computed as npin \cdot p_i and are often decimals like 33.3333.33. Do not round them before computing the statistic, because rounding introduces error. Only observed counts must be whole numbers since they are actual tallies.
What do I do if an expected count is less than 5?
The large counts condition is violated, so the chi-square approximation may be unreliable. On the AP exam you should note this. In practice, categories are sometimes combined to raise expected counts above 5, but you should always state that the condition was not met if it isn't.

Learn this with a teacher, not a page

The Crimsora tutor teaches U8.1 Chi-Square Goodness of Fit live — explaining on a whiteboard, asking you questions, and adapting to where you get stuck.