Loading
Learn to structure a hypothesis test that compares observed categorical counts to a theorized distribution.
Statistical inference about categorical data poses a fundamentally different challenge than inference about means or proportions. When a researcher observes counts spread across multiple categories—such as the number of customers choosing each of six flavors—the question is not whether a single parameter equals some value, but whether an entire distribution of proportions matches a theoretical model. The tool built precisely for this purpose is the chi-square goodness of fit test, and understanding how to set it up correctly is the critical first step in applying it.
The central question the goodness of fit test addresses is deceptively simple: Do the observed counts in a set of categories differ significantly from what a hypothesized distribution predicts? Before any calculation takes place, the test must be set up with precise hypotheses, verified conditions, and a clear identification of the appropriate distribution. Getting the setup wrong can invalidate everything that follows, which is why the AP exam devotes considerable attention to this preliminary phase.
Setting up a chi-square goodness of fit test requires mastery of several interconnected ideas. The test applies to a single categorical variable whose outcomes fall into k mutually exclusive categories. The null hypothesis specifies an exact set of proportions for those categories, and the alternative hypothesis asserts that at least one proportion deviates from its hypothesized value. The following grid outlines the foundational concepts you need before writing a single symbol.
The flowchart captures the entire setup process that should appear in the State and Plan stages of the AP Statistics four-step inference process. In the State step, you write both hypotheses and define the parameter in context—the distribution of a categorical variable in the population. In the Plan step, you name the procedure, verify the three conditions, and note the degrees of freedom. Only after these steps are complete do you proceed to calculate the test statistic and draw a conclusion.
Although the focus of this lesson is the setup, understanding the formula you are setting up to use clarifies why each piece of the setup matters. The chi-square test statistic quantifies the overall discrepancy between observed and expected counts, and its sampling distribution under H₀ is approximately chi-square with k − 1 degrees of freedom—provided the conditions are met.
The most common errors students make on the AP exam involve the hypotheses and conditions. This section breaks down every component so that your setup earns full credit. When writing hypotheses, you must define the parameter in the context of the problem. A generic statement like "the data fit the model" is not sufficient; you need to state what the categorical variable represents and specify every proportion.
A candy company claims that its mixed bag contains 30% red, 20% orange, 20% yellow, 15% green, and 15% blue candies. A statistics student purchases a bag, selects a simple random sample of 150 candies, and records the following observed counts: 56 red, 24 orange, 28 yellow, 20 green, and 22 blue. The student wants to test whether the company's claimed distribution is accurate at the α = 0.05 significance level.
The chi-square goodness of fit test is one of the most versatile tools in the categorical inference toolkit, but it has important limitations that shape how you set it up and interpret its results. The table below contrasts its key strengths against scenarios where caution is required.
| Strengths | Limitations |
|---|---|
| Works with any number of categories (k ≥ 2), making it flexible for nominal and ordinal data alike. | Requires all expected counts to be at least 5; when categories have small expected counts, you may need to combine categories or use an exact test. |
| The null hypothesis can specify any distribution—uniform, historical, theoretical—not just equal proportions. | The test is omnibus: a significant result tells you the distribution differs from H₀ but does not identify which specific categories deviate. |
| Computation is straightforward and supported by all major calculators and software packages. | The test uses counts, not proportions. Entering proportions or percentages into the formula produces incorrect results. |
| Minimal distributional assumptions—no requirement of normality for the underlying variable. | Independence is assumed; repeated measures or clustered data violate this condition and require alternative methods. |
The goodness of fit test is one of three chi-square procedures in the AP Statistics curriculum. Understanding how it relates to the chi-square test for independence and the chi-square test for homogeneity clarifies when to use each and how the setup differs across the three tests.
| Feature | Goodness of Fit | Test for Independence / Homogeneity |
|---|---|---|
| Number of variables | One categorical variable | Two categorical variables (arranged in a two-way table) |
| Data layout | One-way frequency table (single row or column of counts) | Two-way contingency table (r rows × c columns) |
| H₀ statement | The population distribution matches specified proportions | The two variables are independent / the distributions are the same across populations |
| Expected counts | E = n × p (from hypothesized proportions) | E = (row total × column total) / grand total |
| Degrees of freedom | k − 1 | (r − 1)(c − 1) |
Notice that all three tests share the same test statistic formula, χ² = Σ (O − E)²/E, and the same Large Counts condition (all expected counts ≥ 5). The key difference lies in how expected counts are computed and how degrees of freedom are determined. In the goodness of fit test, the expected counts come directly from the hypothesized proportions multiplied by n, whereas in the two-way tests, they are derived from marginal totals. As you move through the AP curriculum, mastering the goodness of fit setup provides the template for the more complex two-variable setups.
Setting up a chi-square goodness of fit test begins with clearly stating the null hypothesis, which specifies a complete set of population proportions for each category of a single categorical variable, and the alternative hypothesis, which asserts that at least one proportion differs. Every proportion must be listed explicitly, and they must sum to 1. The parameter should be defined in the context of the problem.
Before computing anything, you must verify three conditions: the Random condition (data come from a random sample or random process), the Independence condition (sample size is less than 10% of the population), and the Large Counts condition (all expected counts E = n × p ≥ 5). Finally, identify the procedure as a chi-square goodness of fit test with df = k − 1 degrees of freedom. Mastering this setup ensures a solid foundation for the Do and Conclude steps that follow.
Keep learning with more lessons from the same subject.