AP Statistics / Unit 3: Inference for Categorical Data: Proportions / Topic 3.15
NUM8ERS study notes · Topic 3.15

Carrying Out a Chi-Square Test for Homogeneity or Independence

Turn a two-way count table into an evidence-based conclusion. Calculate expected counts, build the chi-square statistic, find its right-tail pp-value and explain what the result means for the populations.

2026–27 curriculum6 worked examples10 practice questions6 visual guides

By the end of this lesson, you should be able to:

  • Calculate every expected count from the marginal totals.
  • Calculate and interpret each cell’s contribution to χ2\chi^{2}.
  • Find the correct degrees of freedom and right-tail pp-value.
  • Interpret the pp-value assuming the contextual null hypothesis is true.
  • Compare the pp-value with α\alpha and write an appropriate population conclusion.
  • Explain why statistical significance, practical importance and causation are different claims.

Before you start: Review Topic 3.14: choosing the test, writing hypotheses and checking conditions. You should recognize row totals, column totals and the grand total of a two-way table.

First time learning this? Follow the three-school preference study from its counts to its conclusion, then try the six worked examples.

Here to revise? Review the calculation checklist, then attempt the ten practice questions before opening hints and solutions.

The concept in 60 seconds

A chi-square test compares observed counts with the counts predicted by the null hypothesis. A small mismatch is ordinary sample variation. A sufficiently large overall mismatch provides evidence against the null model.

Two designs use the same calculation. Homogeneity compares 11 categorical response distribution across independently sampled populations or randomly assigned treatments. Independence investigates association between 22 categorical variables in 11 sampled population. Your design determines which name and conclusion fit.

Visual guide 1: follow the inference chain
1 · Fit the nullExpected counts

Predict each cell from the row total, column total and grand total, after justifying the design.

2 · Combine mismatch11 χ2\chi^{2} statistic

Square each O−EO-E difference, divide by EE and add every interior-cell contribution.

3 · Assess extremenessRight-tail pp-value

Use the chi-square curve with df⁡=(r−1)(c−1)\operatorname{df}=(r – 1)(c – 1). Find the area from the statistic to the right.

4 · Answer the questionContextual conclusion

Compare pp with the preselected α\alpha and describe evidence about the populations or association.

A calculation is part of the inference. Keep the populations, hypothesis and design attached to every step.

The key chain: observed counts → expected counts under H0H_{0} → nonnegative cell contributions → 11 χ2\chi^{2} statistic → a right-tail pp-value → a contextual decision.

The test uses counts of individuals, rather than percentages alone. Each individual contributes to 11 row-and-column combination. All studies on this page are fictional teaching examples; the numerical results are calculated from the stated data.

Quick check: do homogeneity and independence use different statistic formulas?

No. Both use χ2=∑interior cells(O−E)2E\chi^2=\sum_{\text{interior cells}}\frac{(O-E)^2}{E} with df⁡=(r−1)(c−1)\operatorname{df}=(r – 1)(c – 1). Their study designs, hypotheses and population conclusions differ.

Follow the three-school preference study

Researchers select independent SRSs without replacement from Schools A, B and C. The samples contain 100,120, and 80100, 120,\text{ and }80 students, respectively, from populations of 5,000,6,000, and 4,0005{,}000, 6{,}000,\text{ and }4{,}000 students. Each student chooses exactly 11 preferred notes format: digital only, printed only or mixed.

The investigative question is: Is the distribution of preferred notes format the same across the 33 school populations? Use a chi-square test for homogeneity. Choose α=0.05\alpha =0.05 before evaluating the result.

Observed preferred notes formats from independent random samples. Each student appears 1 time1\text{ time}.
School populationDigital onlyPrinted onlyMixedTotal
School A606025251515100100
School B545436363030120120
School C3636292915158080
Total15015090906060300300

H0H_{0}: The distribution of preferred notes format is the same among all students at Schools A, B and C.

HaH_{a}: Those population distributions are not all the same; at least 11 differs.

The null does not require 13\frac13 of students to prefer each category. It requires a common distribution across schools, whose category shares may be unequal. Unequal sample sizes also mean that equal population distributions do not predict equal raw counts.

Verify the setup before calculating a pp-value

  • Randomization and independent observations: Independent SRSs are specified, and each student contributes 11 response. The samples do not consist of the same students measured repeatedly.
  • 10%10\% condition for each sampled population: 100≤0.10(5,000)=500100\le 0.10(5{,}000)=500; 120≤0.10(6,000)=600120\le 0.10(6{,}000)=600; 80≤0.10(4,000)=40080\le 0.10(4{,}000)=400.
  • Expected counts: The next section calculates every interior expectation. The minimum is 1616, so all 99 exceed 55.

Use the same E>5E > 5 criterion as Topic 3.14, following the Fall 2026 AP course framework. Some other texts use E≥5E\ge 5; an exact 55 does not pass the strict wording used here. The sampling 10%10\% check is not required merely for random assignment. A separate finite-population sampling stage can still require its own check.

Quick check: may we combine all 33 school populations for 11 10%10\% check?

No. These samples were separately selected from 33 populations. Check each sample against its own population. A large combined population can hide an overly large sampling fraction in 11 school.

Calculate every expected cell count

Use the table’s margins to calculate the expected count in each interior cell:

E=row total×column totalgrand totalE=\frac{\text{row total}\times\text{column total}}{\text{grand total}}

For School A’s digital-only cell, the row total is 100100, the column total is 150150 and the grand total is 300300:

E=100×150300=50E=\frac{100\times150}{300}=50

Another way to see this: the pooled digital proportion is 150300=0.50\frac{150}{300}=0.50. Under the common-distribution null, 50%50\% of a sample of 100100 is an expected 5050 digital preferences. The combined printed and mixed proportions are 0.300.30 and 0.200.20.

Expected counts under the common-distribution null. Use the 99 interior cells in the statistic.
School populationDigital onlyPrinted onlyMixedTotal
School A505030302020100100
School B606036362424120120
School C4040242416168080
Total15015090906060300300

The expected table preserves the observed row totals, column totals and grand total. For example, School A’s expectations sum to 50+30+20=10050+30+20=100. The digital column sums to 50+60+40=15050+60+40=150. These checks can reveal an arithmetic or data-entry error.

What to remember about EE

  • An observed count OO is what happened; an expected count EE is predicted by the null model using the margins.
  • Expected counts can be fractional. They describe model-based counts, so they need not be whole numbers.
  • Keep full precision for the statistic. Rounding EE too early can change the final pp-value.
  • Check every interior expected cell. The margins are totals, rather than additional response categories.

For an independence test: the same formula predicts a cell count when the 22 categorical variables are independent. The table arithmetic stays the same, while the null claim refers to the 22 variables in 11 population.

Quick check: why is School B’s expected digital count 6060 rather than 5050?

B has a sample of 120120, compared with A’s 100100. Applying the common digital share 0.500.50 gives 120×0.50=60120 \times 0.50=60. A homogeneity null predicts the same proportions, rather than the same counts.

Build the chi-square statistic

The Pearson chi-square statistic adds 11 contribution from every interior cell:

χ2=∑interior cells(O−E)2E\chi^2=\sum_{\text{interior cells}}\frac{(O-E)^2}{E}

Read the formula as: subtract expected from observed, square that difference, divide by the expected count, and add the results. The sum uses all 99 school-study cells.

Visual guide 2: unpack 11 cell contribution
Observed 6060; expected 5050Difference=10\text{Difference}=10

O−E=60−50O-E=60-50. A positive difference is an observed excess in this sample cell.

Remove the signSquared difference=100\text{Squared difference}=100

(60−50)2=100(60-50)^2=100. An equally large shortage would have the same square.

Adjust for EEContribution=2\text{Contribution}=2

10050=2\frac{100}{50}=2. Add this to the other 88 contributions for the school statistic.

A contribution measures this cell’s squared, scaled mismatch with its fitted null expectation. It is not a pp-value or an independent test decision.

For A’s digital cell, O=60O=60 and E=50E=50, so the contribution is (60−50)250=2\frac{(60-50)^2}{50}=2. For A’s printed cell, O=25O=25 and E=30E=30, giving (25−30)230=2530≈0.833333\frac{(25-30)^2}{30}=\frac{25}{30}\approx0.833333.

99 school-study contributions. Displayed contributions are rounded; χ2\chi^{2} uses full precision.
CellObserved OOExpected EEContribution (O−E)2E\frac{(O-E)^2}{E}
A: Digital only606050502.0000002.000000
A: Printed only252530300.8333330.833333
A: Mixed151520201.2500001.250000
B: Digital only545460600.6000000.600000
B: Printed only363636360.0000000.000000
B: Mixed303024241.5000001.500000
C: Digital only363640400.4000000.400000
C: Printed only292924241.0416671.041667
C: Mixed151516160.0625000.062500

χ2=7.6875\chi^{2}=7.6875, using the unrounded cell contributions.

Why square and divide?

Squaring prevents positive and negative differences from cancelling. Under H0H_{0} the margins are preserved, so signed O−EO-E differences can sum to 00 even when many cells differ. Both an excess and a shortage can add evidence against the null.

Dividing by EE adjusts for the count scale. A difference of 1010 with E=50E=50 contributes 22; the same difference with E=100E=100 contributes 11. Comparing only the raw differences misses this scaling.

Visual guide 3: see how the 99 contributions add up
School-by-format cell contributions to the chi-square statisticHorizontal bars for every school-by-format cell contribution in the fictional three-school preference study. In row order A digital, printed, mixed; B digital, printed, mixed; C digital, printed, mixed, the contributions are 2, 0.833333, 1.25; 0.6, 0, 1.5; 0.4, 1.041667, 0.0625. Bars share a zero-based contribution axis and all values are labelled. The unrounded sum is chi-square 7.6875. 0 1 2 Contribution to χ² School A Digital School A Printed School A Mixed School B Digital School B Printed School B Mixed School C Digital School C Printed School C Mixed 2.0000 0.8333 1.2500 0.6000 0.0000 1.5000 0.4000 1.0417 0.0625 Nine cell contributions add to one statistic Three-school preference study · Contribution = (O − E)² / E χ² = 7.6875; df = 4. Every cell counts, including the zero term. Contribution labels are rounded; the sum uses full precision. School-by-format cell contributions to the chi-square statisticHorizontal bars for every school-by-format cell contribution in the fictional three-school preference study. In row order A digital, printed, mixed; B digital, printed, mixed; C digital, printed, mixed, the contributions are 2, 0.833333, 1.25; 0.6, 0, 1.5; 0.4, 1.041667, 0.0625. Bars share a zero-based contribution axis and all values are labelled. The unrounded sum is chi-square 7.6875. 0 1 2 Contribution to χ² School A Digital School A Printed School A Mixed School B Digital School B Printed School B Mixed School C Digital School C Printed School C Mixed 2.0000 0.8333 1.2500 0.6000 0.0000 1.5000 0.4000 1.0417 0.0625
Posted on Google Google
0000003998 : Abdad Alam Shamim Alam profile picture
0000003998 : Abdad Alam Shamim Alam
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
This is the bestest institution I have ever come to and I love it very much.
Posted on Google Google
Aliki S profile picture
Aliki S
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
Posted on Google Google
Ali profile picture
Ali
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
Sly is him
Posted on Google Google
Jitendra Kumar Kumawat profile picture
Jitendra Kumar Kumawat
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
Posted on Google Google
Raahil Hasan profile picture
Raahil Hasan
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
Posted on Google Google
Tina Mudarres profile picture
Tina Mudarres
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
The classes are amazing and my child learnt so much
Posted on Google Google
alisha gadoya profile picture
alisha gadoya
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
I have experienced a lot of good things, it has taught me so many things and from B/Cs I have gone to an A! This is wonderful and Mavish’s class is awesome.
Posted on Google Google
smasher 123 profile picture
smasher 123
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
It’s sensational my kid went. First he only would get C now it’s all A’s really good and recommend
Posted on Google Google
Mosa Al- Samaraie profile picture
Mosa Al- Samaraie
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
AMAZING PRICES GREAT TEACHERS STRAIGHT FORWARD LEARNING STEADY PACE IN TUTORING
Posted on Google Google
Cael Dagnelie profile picture
Cael Dagnelie
Google star 1Google star 2Google star 3Google star 4Google star 5Trustindex verifies that the original source of the review is Google.
I had a great experience learning math with Ms. Mavish. She explains complex topics in a very clear and simple way, which made it easier for me to understand and enjoy the subject. Her patience and dedication really stood out, and she always made sure that everyone in the class was keeping up. I especially appreciated how approachable she was — I never felt afraid to ask questions, and she was always willing to help. Thanks to her teaching, my confidence in math has grown a lot. I’m really thankful for the effort she puts into every lesson!

NUM8ERS is one of finest tutoring institutes in UAE, Located in Al Barsha 1, Dubai. Close to DUBAI AMERICAN ACADEMY (DAA) & AMERICAN SCHOOL OF DUBAI (ASD).