Observed vs expected counts in chi-square

By Jude Wallis · Published

Observed counts are the frequencies you actually recorded in each cell of a table. Expected counts are the frequencies the null hypothesis predicts for those cells, computed from the row and column totals. A chi-square test measures how far the observed counts fall from the expected counts.

AP Statistics: Unit 3 (topics 3.14 Setting Up a Chi-Square Test for Homogeneity or Independence, 3.15 Carrying Out a Chi-Square Test for Homogeneity or Independence). Observed and expected counts drive the chi-square tests in Unit 3 topics 3.14 and 3.15 of the Fall 2026 course. Expected count = (row total x column total)/grand total, and chi-square = sum of (O - E)^2/E with degrees of freedom (rows - 1)(columns - 1). All expected counts must be at least 5. Chi-square goodness-of-fit was removed for Fall 2026, so only the homogeneity and independence tests remain.

Observed vs expected counts: the short answer

A chi-square test compares two sets of numbers in a two-way table. The observed counts are the data you actually collected, cell by cell. The expected counts are what you would predict for each cell if the null hypothesis were true, calculated from the row and column totals.

The test asks how far the observed counts sit from the expected counts. If they are close, the data fit the null hypothesis; if they are far apart, that is evidence against it. The chi-square statistic turns that distance into a single number.

What observed counts are

Observed counts are the raw frequencies in each cell of a two-way table, straight from your data. If you survey 100 people and 30 are in the treatment group who improved, then 30 is an observed count. They are always whole numbers, because you are counting units.

Observed counts are the starting point of any chi-square test for homogeneity or independence. You organize them into a table with row totals, column totals, and a grand total, and those totals feed the expected-count calculation. Nothing about the observed counts assumes the null hypothesis; they are simply what happened.

What expected counts are

Expected counts are the frequencies each cell would hold if the null hypothesis were true, meaning no difference between groups or no association between variables. You compute each one from the margins of the table: expected count=(row total)×(column total)grand total\text{expected count} = \frac{(\text{row total}) \times (\text{column total})}{\text{grand total}}.

Expected counts are usually not whole numbers, and you should not round them to integers, because that distorts the statistic. The AP course also sets a condition for the test to be valid: all expected counts should be at least 5. If an expected count falls below 5, the chi-square approximation may be unreliable, so you check every expected cell before trusting the result.

Observed vs expected counts side by side

FeatureObserved countsExpected counts
Where they come fromYour collected dataThe null hypothesis
How you get themCount the units in each cellrow total×column totalgrand total\frac{\text{row total} \times \text{column total}}{\text{grand total}}
Whole numbersAlwaysUsually not; do not round
Symbol in the formulaOOEE
Depend on the null hypothesisNoYes
Role in the testThe reality being testedThe benchmark to compare against

How the chi-square statistic combines them

The chi-square statistic measures the distance between observed and expected counts relative to the expected counts. You compute it as χ2=(OE)2E\chi^2 = \sum \frac{(O - E)^2}{E}, summing over every cell of the table, where OO is the observed count and EE is the expected count.

Each cell contributes (OE)2E\frac{(O - E)^2}{E}: squaring makes every gap positive, and dividing by EE scales the gap to the size expected there. A large total means the observed counts are far from what the null predicted, which points to a small p-value and evidence against the null. If every observed count matched its expected count exactly, each term would be 0 and χ2\chi^2 would be 0. The degrees of freedom are (rows1)(columns1)(\text{rows} - 1)(\text{columns} - 1).

The classic mix-up and how to avoid it

The classic errors cluster around the expected counts. Some students round expected counts to whole numbers because observed counts are whole, which throws off the statistic; others expect OO to equal EE and panic when it does not, even though some gap is normal from sampling variability. A third slip is forgetting to check that all expected counts are at least 5.

Three habits keep it clean. First, keep expected counts as decimals throughout. Second, treat a gap between OO and EE as expected, and let the chi-square statistic and p-value judge whether the gap is large. Third, before running the test, confirm every expected count is at least 5, since that is a required condition, not an optional check.

Where this fits in AP Statistics

Observed and expected counts drive the chi-square tests in Unit 3, set up in topic 3.14 and carried out in topic 3.15. The Fall 2026 course covers two of these tests, the chi-square test for homogeneity and the test for independence, both built on two-way tables. You can check your arithmetic with the chi-square calculator.

One change to note: the old chi-square goodness-of-fit test was removed from the AP course for Fall 2026, so on the exam you work with two-way tables, not a single row of categories. Writing the hypotheses in context and verifying conditions, including that all expected counts are at least 5, are frequent free-response points, and choosing the right test connects to which statistical test to use and stating null versus alternative hypotheses.

Expected counts and chi-square for a 2 by 2 table

A study records whether patients improved, by group. Treatment: 30 improved, 20 did not. Control: 20 improved, 30 did not. Find the expected counts under the null hypothesis of no difference, then compute the chi-square statistic and its degrees of freedom.

  1. Find the totals. Each row totals 30+20=5030 + 20 = 50. Each column totals 30+20=5030 + 20 = 50 for improved and 20+30=5020 + 30 = 50 for not improved. The grand total is 50+50=10050 + 50 = 100.

  2. Compute the expected count for treatment-improved: (row total)×(column total)grand total=50×50100=2500100=25\frac{(\text{row total}) \times (\text{column total})}{\text{grand total}} = \frac{50 \times 50}{100} = \frac{2500}{100} = 25.

  3. By the same formula every cell has expected count 50×50100=25\frac{50 \times 50}{100} = 25, so all four expected counts are 25.

  4. Confirm the condition: all expected counts equal 25, which is at least 5, so the test is valid.

  5. Find each cell's contribution (OE)2E\frac{(O - E)^2}{E}. Treatment-improved: (3025)225=5225=2525=1\frac{(30 - 25)^2}{25} = \frac{5^2}{25} = \frac{25}{25} = 1.

  6. The other three cells each give (2025)225=(5)225=2525=1\frac{(20 - 25)^2}{25} = \frac{(-5)^2}{25} = \frac{25}{25} = 1 or (3025)225=1\frac{(30 - 25)^2}{25} = 1.

  7. Sum over all cells: χ2=1+1+1+1=4\chi^2 = 1 + 1 + 1 + 1 = 4.

  8. Degrees of freedom: (rows1)(columns1)=(21)(21)=1(\text{rows} - 1)(\text{columns} - 1) = (2 - 1)(2 - 1) = 1.

Every expected count is 25, all at least 5, and the chi-square statistic is χ2=4\chi^2 = 4 with 1 degree of freedom. The observed counts sit 5 units from each expected count, and squaring and scaling those gaps gives a contribution of 1 per cell, for a total of 4.

Frequently asked questions

How do you calculate expected counts?

For each cell of a two-way table, multiply its row total by its column total and divide by the grand total: expected count=row total×column totalgrand total\text{expected count} = \frac{\text{row total} \times \text{column total}}{\text{grand total}}. These are the counts you would expect if the null hypothesis of no difference or no association were true, and you keep them as decimals.

Why don't observed counts equal expected counts?

Because of sampling variability. Even when the null hypothesis is true, random sampling makes the observed counts differ from the exact expected counts. The chi-square statistic and its p-value decide whether the gap is larger than random variation would explain; if the counts matched exactly, chi-square would be 0.

What if an expected count is below 5?

The AP condition requires all expected counts to be at least 5. If one falls below 5, the chi-square approximation may be unreliable, so the test result is not trustworthy. You would need more data or a combined category, and you should state the failed condition rather than proceed as if it held.

Is the goodness-of-fit test on the AP exam?

No. The chi-square goodness-of-fit test was removed from the AP Statistics course for Fall 2026. The exam covers the chi-square test for homogeneity and the test for independence, both of which use two-way tables of observed and expected counts.