Math Core

Lesson 12.4 · Probability

Two-way tables and probability

Surveys often record two things about each person: grade and favorite sport, age and phone brand, whether someone was vaccinated and whether they got sick. A two-way table organizes that kind of data so you can read off probabilities, including conditional ones, and decide whether the two variables are related.

Reading a two-way table

Definition

Two-way table

A two-way table shows counts for two categorical variables at once. One variable labels the rows and the other labels the columns. Each inner cell counts the people (or items) in one row category and one column category. The Total row and column give the counts for each category alone.

Here is a survey of 150150 people about whether they prefer dogs or cats.

DogsCatsTotal
Adults454530307575
Teens505025257575
Total95955555150150
  • The inner cells are joint counts: 5050 people are teens and prefer dogs.
  • The totals on the edge are marginal counts: 9595 people prefer dogs, regardless of age.
  • Always check that each row and column adds up. Here 45+30=7545 + 30 = 75 and 45+50=9545 + 50 = 95.

Three kinds of probability

Suppose one of these 150150 people is chosen at random.

Probabilities from a two-way table

  • Marginal probability (one variable only): divide a total by the grand total. P(teen)=75150=12P(\text{teen}) = \dfrac{75}{150} = \dfrac{1}{2}.
  • Joint probability (both variables): divide an inner cell by the grand total. P(teen and dogs)=50150=13P(\text{teen and dogs}) = \dfrac{50}{150} = \dfrac{1}{3}.
  • Conditional probability (given one variable): divide an inner cell by the total of the given row or column. P(dogs∣teen)=5075=23P(\text{dogs} \mid \text{teen}) = \dfrac{50}{75} = \dfrac{2}{3}.

The conditional one is where the table really helps. "Given teen" means you look only at the Teens row, so its total, 7575, becomes the denominator.

Worked example: Which way does the bar go?

Using the pet table, find P(dogs∣teen)P(\text{dogs} \mid \text{teen}) and P(teen∣dogs)P(\text{teen} \mid \text{dogs}).

Given teen: restrict to the Teens row. Of 7575 teens, 5050 prefer dogs.

P(dogs∣teen)=5075=23.P(\text{dogs} \mid \text{teen}) = \frac{50}{75} = \frac{2}{3}.

Given dogs: restrict to the Dogs column. Of 9595 dog lovers, 5050 are teens.

P(teen∣dogs)=5095=1019.P(\text{teen} \mid \text{dogs}) = \frac{50}{95} = \frac{10}{19}.

Same cell, different denominators, different answers.

Common mistake

The most common error is using the grand total when the question says "given." If the question gives you a condition, the denominator is the total for that row or column, never the grand total.

"Or" from a table

For P(A or B)P(A \text{ or } B), use the addition rule, or add up the cells directly without repeating any.

Worked example: An or question

Using the pet table, find P(adult or cats)P(\text{adult or cats}).

With the addition rule:

P(adult or cats)=75150+55150−30150=100150=23.P(\text{adult or cats}) = \frac{75}{150} + \frac{55}{150} - \frac{30}{150} = \frac{100}{150} = \frac{2}{3}.

Check by counting cells: every adult (45+3045 + 30) plus the teens who prefer cats (2525) gives 100100 people. Same answer.

Relative frequency tables

Divide every entry by the grand total and you get a relative frequency table. Each entry is now a joint or marginal probability, and the grand total becomes 11.

DogsCatsTotal
Adults0.300.300.200.200.500.50
Teens≈0.33\approx 0.33≈0.17\approx 0.170.500.50
Total≈0.63\approx 0.63≈0.37\approx 0.3711

You can compute conditional probabilities from this table too, with the formula P(B∣A)=P(A∩B)P(A)P(B \mid A) = \dfrac{P(A \cap B)}{P(A)}. For example, P(dogs∣adult)=0.300.50=0.6P(\text{dogs} \mid \text{adult}) = \dfrac{0.30}{0.50} = 0.6.

Are the variables independent?

Two variables are independent if knowing one tells you nothing about the other. In a table, that means the conditional probability is the same in every row, and equal to the overall (marginal) probability.

Worked example: Testing independence in a table

Pet survey. P(dogs∣adult)=4575=0.6P(\text{dogs} \mid \text{adult}) = \dfrac{45}{75} = 0.6, but P(dogs∣teen)=5075≈0.67P(\text{dogs} \mid \text{teen}) = \dfrac{50}{75} \approx 0.67. Since these differ, preferring dogs is not independent of age group in this survey.

Sports survey. Here is a different school survey of 200200 students.

Plays a sportNo sportTotal
Grade 948487272120120
Grade 10323248488080
Total8080120120200200

P(sport∣grade 9)=48120=0.4P(\text{sport} \mid \text{grade } 9) = \dfrac{48}{120} = 0.4 and P(sport∣grade 10)=3280=0.4P(\text{sport} \mid \text{grade } 10) = \dfrac{32}{80} = 0.4, which also equals P(sport)=80200=0.4P(\text{sport}) = \dfrac{80}{200} = 0.4. Playing a sport is independent of grade here. You can confirm it with the product test: P(grade 9 and sport)=48200=0.24P(\text{grade 9 and sport}) = \dfrac{48}{200} = 0.24, and P(grade 9)⋅P(sport)=0.6×0.4=0.24P(\text{grade } 9) \cdot P(\text{sport}) = 0.6 \times 0.4 = 0.24.

Tip

To fill in a table with missing entries, remember that every row and every column must add to its total. Fill in whatever cell has only one unknown in its row or column, then repeat.

Practice

Problems 1–6 use this survey of 150150 juniors and seniors about their favorite kind of movie.

ComedyActionDramaTotal
Juniors3030252515157070
Seniors2020353525258080
Total505060604040150150
Practice 1

A student is chosen at random. What is P(senior)P(\text{senior})?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 2

What is P(junior and comedy)P(\text{junior and comedy})?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 3

What is P(action∣senior)P(\text{action} \mid \text{senior})?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 4

What is P(senior∣action)P(\text{senior} \mid \text{action})?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 5

What is P(junior or drama)P(\text{junior or drama})?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 6

Is preferring drama independent of being a senior?

Practice 7

A club surveyed 100100 members from two groups. Some entries are missing.

YesNoTotal
Group A18184040
Group B6060
Total4545100100

What is P(yes∣Group B)P(\text{yes} \mid \text{Group B})?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 8

In a survey of 200200 people, 8080 own a bike and 7575 are under 3030 years old. Suppose owning a bike is independent of being under 3030. How many people would you expect to be under 3030 and own a bike?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.