AP Statistics · Exam guide
AP Statistics Chi-Square Test Explained: Homogeneity and Independence with a Worked Example
The chi-square test compares counts in a table. On the AP Statistics exam it appears as a test of homogeneity (does the distribution of a categorical variable differ across groups?) or independence (are two categorical variables related within one sample?). The data below are made up for practice.
A made-up experiment
Researchers randomly assign 100 patients to one of two treatments, 50 each, and record whether each improved.
| Improved | Did not improve | Total | |
|---|---|---|---|
| Treatment A | 30 | 20 | 50 |
| Treatment B | 18 | 32 | 50 |
| Total | 48 | 52 | 100 |
| Step | Work |
|---|---|
| State | H0: the distribution of improvement is the same for both treatments. Ha: the distribution of improvement is different for the two treatments. |
| Plan | Chi-square test for homogeneity. Patients were randomly assigned to treatments. All expected counts are at least 5 (see below). |
| Do | Expected count = row total times column total divided by the table total: 50 times 48 / 100 = 24 improved in each group, and 50 times 52 / 100 = 26 not improved in each group. Chi-square = (30-24)^2/24 + (20-26)^2/26 + (18-24)^2/24 + (32-26)^2/26 = 1.50 + 1.38 + 1.50 + 1.38 = 5.77. Degrees of freedom = (2 - 1)(2 - 1) = 1. The p-value is about 0.016. |
| Conclude | The p-value of 0.016 is less than 0.05, so we reject H0. There is convincing evidence that the distribution of improvement differs between treatment A and treatment B. |
Homogeneity or independence?
| Test | How the data were collected | Hypotheses |
|---|---|---|
| Homogeneity | Separate samples (or random assignment) from several groups, one categorical response. | The distribution of the response is the same in every group. |
| Independence | One sample, two categorical variables measured on each individual. | The two variables are independent in the population. |
The arithmetic is the same for both. The wording of the hypotheses and conclusion is what changes.
It does not say what is different, and the hypotheses were never stated in context.
It ties the decision to the p-value and uses the language of the hypotheses.
Common mistakes
- Using observed counts instead of expected counts to check the condition.
- Computing degrees of freedom as the number of cells minus 1 instead of rows minus 1 times columns minus 1.
- Writing hypotheses about means or proportions instead of distributions or association.
- Using percentages instead of counts in the calculation.
- Claiming cause and effect from an observational table. Random assignment is what supports it.
Frequently asked questions
What conditions does a chi-square test need?
Random sampling or random assignment, a sample less than 10 percent of the population, and all expected counts at least 5.
How do I find expected counts?
Row total times column total, divided by the table total.
Does a small p-value tell me which cell is responsible?
No. Compare observed and expected counts in each cell to see where the biggest differences are.
Is a goodness-of-fit test on the exam?
The 2026 course description this site follows covers homogeneity and independence. Check the current description for goodness of fit.
Where can I find the official scoring rules?
Exam formats change a little from year to year, so check the current course and exam description on the College Board site before test day.
Keep practicing
Every unit in the AP Statistics course ends with a ten-problem practice set, three multiple choice and seven free response, with worked answers. These free lessons also build the skills the free-response section tests:
See the AP Statistics course Free lessons and lesson list
Other free-response guides:
- AP Statistics FRQ Guide: How Free-Response Answers Are Scored
- AP Statistics Inference for Proportions Explained: Intervals and Tests with a Worked Example
- AP Statistics Inference for Means Explained: The One-Sample t Test and Checking Conditions
- AP Statistics Regression Questions Explained: Interpreting Slope, r-Squared and Residuals
AP is a registered trademark of the College Board, which is not affiliated with and does not endorse this site. This guide is our own explanation of the question types and scoring. For the official scoring guidelines, see the College Board.