6m left·0%
Reading Time: 6 min
Last Updated: September 9, 2026
Main Ideas: 5
Reading Time: 6 min
Last Updated: September 9, 2026
Main Ideas: 5

Topic 3.15 Notes – Carrying Out a Chi-Square Test for Homogeneity or Independence

Verified for 2027 AP® Statistics Exam
Read aloud
A chi-square test for homogeneity or independence uses a two-way table of counts to compare what you observed to what you would expect if the null hypothesis were true. In this topic, the math for the two tests is the same, but the study design, hypotheses, and conclusion wording are different, and that difference matters a lot on quizzes and FRQs.

What a Chi-Square Test for Homogeneity or Independence Does

These tests work with categorical data in a two-way table. They compare observed counts to expected counts under H0H_0.

A two-way table like the one below is the basic setup for both tests.

  • Test of independence
    • You have one random sample from one population
    • You record two categorical variables on each individual
    • You ask whether the variables are associated
  • Test of homogeneity
    • You have separate random samples from different populations, or different treatments in an experiment
    • You measure one categorical response variable
    • You ask whether the category distributions are the same across groups

Same calculations, different story. That is a favorite AP Stats distinction.

Study guide illustration

Two-way table of observed counts

Keep the full inference setup visible when you do the test. You still need hypotheses, conditions, and a conclusion in context.

Expected Counts and the Chi-Square Statistic

An expected count is what should land in a cell if H0H_0 were true.

E=(row total)(column total)table total E=\frac{(\text{row total})(\text{column total})}{\text{table total}}

A quick example. If a cell is in a row with total 120, a column with total 156, and the table total is 300, then

E=(120)(156)300=62.4 E=\frac{(120)(156)}{300}=62.4

A few things students forget:

  • Expected counts come from the null hypothesis
    • independence means counts expected if the variables are unrelated
    • homogeneity means counts expected if all groups have the same distribution
  • Expected counts can be decimals
  • The expected table keeps the same row totals and column totals as the observed table

The test statistic is

χ2=∑(O−E)2E \chi^2=\sum \frac{(O-E)^2}{E}

  • Use only the interior cells, never the row or column totals
  • Each cell’s fraction is that cell’s contribution
  • χ2≥0\chi^2\ge 0 always
  • Bigger χ2\chi^2 means bigger disagreement between observed and expected

The statistic does not tell you direction. To describe the pattern, compare observed and expected counts cell by cell.

Carrying Out the Test

  1. Identify the procedure
    • One sample + two variables = independence
    • Multiple samples/treatments + one response = homogeneity
  2. State hypotheses in context
    • Independence
      H0H_0 says the variables are independent in the population.
      HaH_a says the variables are associated.
    • Homogeneity
      H0H_0 says the distributions are the same across populations or treatments.
      HaH_a says they are not all the same.
  3. Check conditions
    • Random sample(s) or randomized experiment
    • 10% condition for sampling without replacement
    • Every expected count > 5
  4. Calculate expected counts and show at least one example
  5. Compute χ2\chi^2 from all interior cells
  6. Find degrees of freedom
    df=(rows−1)(columns−1) \text{df}=(\text{rows}-1)(\text{columns}-1)
  7. Find the p-value
    P(χdf2≥χobserved2) P(\chi^2_{\text{df}} \ge \chi^2_{\text{observed}})

Chi-square tests here are always right-tailed.

P-Value, Decision, and Conclusion

The p-value is the probability, assuming H0H_0 is true, of getting a chi-square statistic at least as large as the one observed.

Decision rule:

  • if p-value ≤α\le \alpha, reject H0H_0
  • if p-value >α> \alpha, fail to reject H0H_0

Your conclusion has to match the test:

  • Independence
    “There is convincing evidence of an association between commuting method and residential zone among adult residents of the town.”
  • Homogeneity
    “There is convincing evidence that the distribution of commuting method differs between central-zone and outer-zone adult residents.”

After a significant result, describe the pattern carefully using observed vs. expected counts or conditional percents. Say which categories were higher or lower than expected. Don’t claim every category differs.

Common Mistakes and Scope of Inference

Common errors:

  • Checking the large-counts condition with observed counts instead of expected counts
  • Including totals in the χ2\chi^2 sum
  • Using n−1n-1 for df instead of (r−1)(c−1)(r-1)(c-1)
  • Forgetting the p-value is a right-tail area
  • Saying “accept H0H_0” after a nonsignificant result

Scope of inference depends on design:

  • Random sampling lets you generalize to the population(s)
  • Random assignment lets you talk about cause and effect for treatments
  • An observational study can show association, not causation
  • Statistical significance does not measure strength or explain why the relationship exists

Key Takeaways

Independence and homogeneity use the same calculations, but the study design changes the hypotheses and conclusion.
Expected counts use (row total×column total)/table total(\text{row total}\times\text{column total})/\text{table total}, and they do not need to be whole numbers.
The large-counts condition uses expected counts, and every expected cell count must be greater than 5.
The chi-square statistic adds only interior cell contributions, never row or column totals.
Degrees of freedom are (r−1)(c−1)(r-1)(c-1), not n−1n-1.
The p-value is always P(χdf2≥χobs2)P(\chi^2_{\text{df}} \ge \chi^2_{\text{obs}}), so it is always a right-tail area.
Failing to reject H0H_0 means there is not convincing evidence of a difference or association, not that the variables are independent or the distributions are the same.
After significance, use observed vs. expected counts to describe the pattern that seems to drive the result.

AP® is a trademark registered by the College Board, which is not affiliated with, and does not endorse this website.

Notes

1 credit used · 5/5 remaining