---
title: "Expected if the distributions match. | FiveStudy"
description: "A university system asks students on three campuses which class format they prefer: in person, hybrid, or online. A two-proportion test cannot answer this. There are three groups and three response ca"
url: https://fivestudy.com/guides/apstats-3-14-setting-up-chi-square
---

[AP Statistics](https://fivestudy.com/ap-statistics) · Study guide

# Expected if the distributions match.

[Figure: FiveStudy]

FiveStudy

AP® Statistics · Unit 3 · Inference for Categorical Data: Proportions

AP® Statistics · Unit 3 · Inference for Categorical Data: Proportions

# Setting Up a *Chi-Square* Test

How the chi-square statistic and its distributions work, how to choose between the test for homogeneity and the test for independence, and how to write the hypotheses and check the conditions, including expected counts.

1. Chi-square distributions 2. Which test? 3. Hypotheses 4. Expected counts and conditions

The idea in one paragraph

A chi-square test works with a two-way table of counts. H₀ predicts what the counts should be (the **expected counts**); the chi-square statistic measures how far the observed counts are from those predictions. Use the **test for homogeneity** to compare a variable’s distribution across two or more populations or treatments, and the **test for independence** to look for an association between two variables in one population.

## 1 The chi-square statistic and its distributions

The chi-square statistic, \(\chi^2\), measures the distance between the observed and expected counts relative to the expected counts. Every cell adds a nonnegative amount, so \(\chi^2\) is never negative. A value near 0 means the counts are close to what H₀ predicts; a large value means they are far off.

The chi-square distributions are a family of density curves. Each has positive values and is skewed right, and each is identified by its degrees of freedom (df). As df increases, the skew becomes less pronounced.

**Figure 1.** A chi-square statistic can never be negative, so every chi-square distribution starts at 0 and is skewed right. With more degrees of freedom the peak moves right and the skew becomes less pronounced.

## 2 Homogeneity or independence?

|  | Test for homogeneity | Test for independence |
| --- | --- | --- |
| Question | Do the distributions of one categorical variable differ across populations or treatments? | Are two categorical variables associated in one population? |
| Data | Independent random samples from each population, or a randomized experiment | One random sample, with two variables recorded on each individual |
| Refer to | The categorical variable and the populations | Both categorical variables and the population |

**Figure 2.** Both tests use a two-way table, so the table alone does not decide. Separate samples (or treatment groups) compared on one variable call for homogeneity; one sample classified two ways calls for independence.

Worked Example 1 Homogeneity or independence?

### Three studies

Name the chi-square test for each study.

1. Independent random samples of students at three high schools are asked how they usually get to school.
2. One random sample of 240 students at a large high school records each student’s grade and whether they have a part-time job.
3. A teacher randomly assigns 90 students to three review formats and records whether each rates the review helpful, neutral, or unhelpful.
1. 1Study 1: three populations (schools), each sampled separately, one variable. Homogeneity.
2. 2Study 2: one population, one sample, two variables recorded on each student. Independence.
3. 3Study 3: three treatments assigned at random, one response variable. Homogeneity (comparing treatments).

**Answer:** 1 and 3: chi-square test for homogeneity. 2: chi-square test for independence.

Common Mistake 1 · Choosing the test from the shape of the table

The same table of counts could come from either design. Decide from how the data were produced: separate samples or treatment groups means homogeneity; one sample sorted two ways means independence.

## 3 Hypotheses

| Test | H₀ | Hₐ |
| --- | --- | --- |
| Homogeneity | There is no difference in the distributions of [variable] across [populations or treatments] | There is a difference in the distributions of [variable] across [populations or treatments] |
| Independence | There is no association between [variable 1] and [variable 2] in [population] (they are independent) | There is an association between [variable 1] and [variable 2] in [population] (they are not independent) |

Worked Example 2 Hypotheses for homogeneity

### Getting to school

State the hypotheses for Study 1.

1. 1Homogeneity hypotheses are about distributions: name the categorical variable and the populations.

**Answer:** H₀: There is no difference in the distributions of how students usually get to school among all students at School A, School B, and School C. Hₐ: There is a difference in those distributions.

Common Mistake 2 · Writing hypotheses about the samples

The sample percentages clearly differ (40%, 30%, 40% take the bus). The question is whether the distributions differ among *all* students at the three schools. Hypotheses always describe populations.

## 4 Expected counts and conditions

Expected counts are the counts H₀ predicts. If the distributions are the same, each row should split in the same proportions as the column totals, which gives

\[ \text{expected count} = \frac{(\text{row total})(\text{column total})}{\text{table total}} \]

**Figure 3.** If H₀ is true, every school has the same distribution as the combined one: 37.5% bus, 37.5% car, 25% walk or bike. The expected counts apply those combined percentages to each school’s sample size. The test asks whether the schools’ bars differ by more than random sampling would explain.

| Condition | Check |
| --- | --- |
| Randomization | Independence: one random sample. Homogeneity: independent random samples, or a randomized experiment |
| 10% condition | When sampling without replacement, \(n \le 0.10N\) for each sample (not needed for an experiment) |
| Expected counts | Every expected count is at least 5 |

Worked Example 3 Expected counts and conditions

### Getting to school

The samples gave the table below. The three schools enroll 1,800, 1,200, and 2,000 students. Find the expected counts and check the conditions.

|  | Bus | Car | Walk or bike | Total |
| --- | --- | --- | --- | --- |
| School A | 60 | 54 | 36 | 150 |
| School B | 30 | 48 | 22 | 100 |
| School C | 60 | 48 | 42 | 150 |
| Total | 150 | 150 | 100 | 400 |

1. 1Expected count = (row total)(column total) / table total. For School A, Bus: \(150 \times 150 / 400 = 56.25\).
2. 2The other expected counts follow the same way (table below). The smallest is 25.
3. 3Randomization: independent random samples from the three schools. 10% condition: 150 ≤ 180, 100 ≤ 120, and 150 ≤ 200.
4. 4Expected counts condition: every expected count is at least 5.

**Answer:** All conditions are met for a chi-square test for homogeneity.

| Expected | Bus | Car | Walk or bike |
| --- | --- | --- | --- |
| School A | 56.25 | 56.25 | 37.5 |
| School B | 37.5 | 37.5 | 25 |
| School C | 56.25 | 56.25 | 37.5 |

Common Mistake 3 · Checking the observed counts instead of the expected counts

The condition is about the *expected* counts. An observed count of 3 is fine if its expected count is 8; an observed count of 12 does not help if some cell’s expected count is 2. In a sample of 30, a row total of 10 and a column total of 6 give an expected count of \(10 \times 6/30 = 2\), so the condition fails.

Worked Example 4 Hypotheses and conditions for independence

### Grade and part-time jobs

A random sample of 240 students at a high school with 2,600 students found that 12 of 80 tenth graders, 22 of 80 eleventh graders, and 34 of 80 twelfth graders have a part-time job. Set up the test.

1. 1H₀: There is no association between grade level and having a part-time job among students at the school. Hₐ: There is an association between them.
2. 2Randomization: one random sample. 10% condition: 240 ≤ 0.10(2,600) = 260.
3. 3Column totals: 68 with a job, 172 without. Expected counts: \(80 \times 68/240 \approx 22.67\) with a job and \(80 \times 172/240 \approx 57.33\) without, in each grade. All are at least 5.

**Answer:** A chi-square test for independence is appropriate.

Common Mistake 4 · Running the test on percentages

The chi-square statistic is built from counts. Entering 40%, 36%, 24% instead of 60, 54, 36 changes the result, because the size of the sample matters. Always use the counts.

### Quick reference

| Piece | Homogeneity | Independence |
| --- | --- | --- |
| Design | Separate samples or treatments; one variable | One sample; two variables |
| H₀ | No difference in distributions | No association (independent) |
| Randomization | Independent random samples or random assignment | A random sample |
| Expected count | (row total)(column total) ÷ table total | Same formula |
| Expected counts condition | All at least 5 | All at least 5 |

FiveStudy AP® Statistics · Setting up a chi-square test
