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 , and read a p-value from the chi-square distribution with . Getting the conclusion right in context is where the AP exam awards points, so we finish there.
In this lesson you will learn to state hypotheses about a distribution, check the conditions, build expected counts, compute the test statistic , and read a p-value from the chi-square distribution with . 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.
: the categorical variable follows the specified distribution (for example, , , , ).
: at least one of the stated proportions is incorrect.
A common misconception is writing as a single proportion being different, or using 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.
The hypotheses are always about proportions across categories. The null hypothesis states the claimed distribution; the alternative says the claim is wrong somewhere.
: the categorical variable follows the specified distribution (for example, , , , ).
: at least one of the stated proportions is incorrect.
A common misconception is writing as a single proportion being different, or using 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.
The large counts condition uses expected counts, not observed counts. Compute each expected count as , where is the total sample size and is the proportion claimed under for that category.
For example, if and claims , then . Do this for every category; the expected counts must sum to , which is a useful arithmetic check.
Students often forget that expected counts do not need to be whole numbers. An expected count of 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."
| Condition | What to check |
|---|---|
| Random | Data come from a random sample or randomized process |
| Independence (10%) | Sample size is less than 10% of the population when sampling without replacement |
| Large counts | Every expected count is at least 5 |
For example, if and claims , then . Do this for every category; the expected counts must sum to , which is a useful arithmetic check.
Students often forget that expected counts do not need to be whole numbers. An expected count of 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: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 predicts, so large gives evidence against the null.
The degrees of freedom for a GOF test is , where is the number of categories. Not the sample size, not ; simply one less than the number of categories.
The p-value is always the area to the right of your 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 . You can find this with technology (cdf with lower bound = your statistic, upper bound = large number like ) 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.
The degrees of freedom for a GOF test is , where is the number of categories. Not the sample size, not ; simply one less than the number of categories.
The p-value is always the area to the right of your 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 . You can find this with technology (cdf with lower bound = your statistic, upper bound = large number like ) 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 (use if none is given).
If : reject . There is convincing evidence that the true distribution differs from the claimed distribution.
If : fail to reject . 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 is less than , we reject ; 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" ; 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 ; the largest term flags the category driving the result. This kind of follow-up analysis appears often on free-response questions.
If : reject . There is convincing evidence that the true distribution differs from the claimed distribution.
If : fail to reject . 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 is less than , we reject ; 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" ; 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 ; 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 is true, computed as .
- Chi-square statistic.
- , measuring total relative discrepancy between observed and expected counts.
- Degrees of freedom.
- For a GOF test, , where is the number of categories.
- P-value.
- The probability, assuming is true, of getting a 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 ; 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 whether the observed distribution differs from the company's claim.
State hypotheses. : the true drop distribution is , , . : 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: , , . All are at least 5, so the large counts condition is met. (Notice , matching .)
Compute the statistic.Find the p-value. With , the right-tail area beyond is approximately .
Conclude. Since , we reject . 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 (), suggesting fewer common drops than claimed.
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: , , . All are at least 5, so the large counts condition is met. (Notice , matching .)
Compute the statistic.Find the p-value. With , the right-tail area beyond is approximately .
Conclude. Since , we reject . 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 (), 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?
- 4
- 5
- 6
- 36
Answer: 5
For a goodness-of-fit test, where is the number of categories. With 6 categories, . 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?
- The observed counts exactly equal the expected counts
- The p-value is greater than the significance level
- The chi-square statistic is large, producing a small p-value
- The expected counts are all below 5
Answer: The chi-square statistic is large, producing a small p-value
A large means observed counts differ substantially from expected, giving a small right-tail p-value. When that p-value is at or below , we reject . Exactly equal counts would give (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 .
Answer: with ; fail to reject .
Hypotheses: : ; : at least one proportion differs. Expected counts: , , . Statistic: . With , the p-value is about , which is greater than , so we fail to reject ; 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 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 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 and are often decimals like . 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.