The display that turns the arithmetic of this chapter into reading. A contingency table shows sample values in relation to two variables that may be dependent on one another, with a cell for every combination, row and column totals in the margins, and a grand total in the corner. A joint probability is one cell over the grand total; a marginal probability is a margin over the grand total; and a conditional probability is a cell over its own row or column total, which is section 3.1's reduced sample space made literal. Section 3.2's independence test becomes a comparison of two fractions read from the same table.
Subject: Statistics · 67 slides · symbolic lesson
Open the interactive version of this deck
Title
Statistics · Chapter 3 — Probability Topics
Every probability in the chapter, read off one grid of counts
Objectives
Sections 3.1 to 3.3 gave you the vocabulary: joint, conditional, independent, the multiplication and addition rules. Each rule needed an ingredient you usually had to be handed, such as the chance of both events or the chance of one given the other. A contingency table hands you all of them at once. Once you can read it, every probability in the chapter is one number on the table divided by another.
The whole lesson turns on one skill: choosing the denominator. The numerator is almost always obvious once you find the right cell. The denominator is where the marks are lost, because the same cell divided by three different totals answers three different questions.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 183 — the section introduction
Warm-up
Everything today is a formula you already know, made concrete. Write these three from memory before you look at the answer.
Discussion prompt
Write the formula for the probability of A given B, the addition rule for A OR B, and the test that A and B are independent.
Keep the conditional formula especially close. Its denominator is the probability of the event you are given, not the probability of everything. On a table, that becomes a very literal instruction: divide by the total of the row or column you were given, not by the grand total.
Also remember what independence is not. It is not the same as mutually exclusive, which means the probability of A AND B is zero. On a table, mutually exclusive means an empty cell; independent means the rows split in the same proportions. They are different questions, and this lesson tests both.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.3, pp. 179-181 — the rules revisited here
Section
Part 1
Concept
Suppose a study records two things about each of 755 drivers: whether they use a cell phone while driving, and whether they had a speeding violation in the last year. Each driver lands in exactly one of four boxes. Count the drivers in each box and you have a contingency table.
Figure (svg): Table 3.3 drawn as a grid. The four interior counts 25, 280, 45 and 405 are shaded blue; the row totals 305 and 450 and the column totals 70 and 685 are shaded orange; the grand total 755 in the corner is shaded yellow. A legend on the right names the three kinds of number.
contingency table — A table that shows sample counts for every combination of two variables, with each row total and column total in the margins and the sample size in the corner. It is used to see whether one variable depends on, or is contingent on, the other.
Three kinds of number live in it. A cell, shaded blue, counts drivers with one value of each variable, such as the 25 who use a phone AND had a violation. A margin, shaded orange, counts everyone with one value of one variable regardless of the other, such as the 305 phone users. The corner counts the whole sample.
Get used to where each lives. Cells are inside the box, margins run along the right edge and the bottom, and the corner is where the two margins meet. Every question in this lesson points at one of these places before it points at any number.
The book calls the data fictional, and says the table displays sample values in relation to two variables that may be dependent on one another. That phrase is the reason the table exists: its layout is designed to let you see whether phone use and violations go together.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, pp. 183-184 — Example 3.20, Table 3.3
Concept
Before you compute anything, add the table up. Every driver is in exactly one row, so the row totals must add to the whole sample. Every driver is also in exactly one column, so the column totals must add to the whole sample too. Two routes, one answer.
\[ 25 + 280 = 305, \qquad 45 + 405 = 450 \]
\[ 25 + 45 = 70, \qquad 280 + 405 = 685 \]
Those four sums rebuild the margins from the cells. Now add the margins themselves, once along the side and once along the bottom.
\[ 305 + 450 = 755 \]
\[ 70 + 685 = 755 \]
Both give 755, the book's own check. If one cell had been mistyped, it would spoil one row total and one column total, and the two grand totals would stop agreeing. So this thirty-second habit catches almost every copying error before it can wreck six answers downstream.
What it cannot catch is a table that adds up perfectly but describes the world badly, because the sample was biased or the answers were dishonest. The margin check is proofreading, not validation.
In a tutoring session, make the check visible: write the two sums beside the table before any probability appears. It costs half a minute, and it turns every later answer into one you can defend.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 184 — the check after Table 3.3
Picture it
A table of counts can be drawn so that area is people. Make a rectangle for the whole sample, cut it into two columns as wide as the two row totals, then shade the violators in each column from the bottom up.
Figure (svg): A rectangle standing for all 755 drivers, split into a left column of width 305 for phone users and a right column of width 450 for non-users. In each column a thin bottom band is shaded for drivers with a violation: 25 of 305 on the left and 45 of 450 on the right; the two bands are almost the same height.
The left column is 305 drivers wide, the right one 450. The red band on the left is 25 of those 305 drivers; the band on the right is 45 of 450. What you should notice is how similar the two band heights are: 0.082 against 0.100.
\[ \frac{25}{305} = 0.082, \qquad \frac{45}{450} = 0.100 \]
In this fictional data, phone users actually had slightly fewer violations. Hold on to that picture. Much later in the lesson you will ask whether the two variables are independent, and the answer is exactly the question of whether those two bands are the same height.
Area pictures like this are worth drawing by hand for any two-by-two table. They force you to decide which variable goes across and which goes up, and that decision is exactly the decision about which conditional you are looking at.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 184 — Table 3.3 redrawn
Prediction
Tables in homework often arrive with holes in them. Before you fill one, work out how much information a two-by-two table really carries.
Predict first
A two-by-two contingency table has both row totals, both column totals and the grand total filled in. How many of the four interior cells must you be given before you can complete it?
Correct: One
Why: Give yourself any one cell. Its row total minus it gives the other cell in that row; its column total minus it gives the other cell in that column; and the last cell follows from either of those. With the margins fixed, one number decides the whole interior.
This fact matters twice. It tells you how to complete a table: look for a row or column with exactly one blank. And it will return in Chapter 11, where it becomes the degrees of freedom of a test for independence.
Try it on the speeding table. Keep the margins and pretend you know only the 25 phone users with a violation. The rest of their row is 305 minus 25, the rest of their column is 70 minus 25, and the last cell is 450 minus 45. All four cells come back.
It also explains why a table can be faked so easily and caught so easily. Change one cell and at least three others must change with it, or a margin breaks.
Step zero
A random sample of 100 hikers was asked where they prefer to hike. The book gives this table with six numbers missing.
| coastline | lakes and streams | mountain peaks | total | |
|---|---|---|---|---|
| women | 18 | 16 | ? | 45 |
| men | ? | ? | 14 | 55 |
| total | ? | 41 | ? | ? |
Discussion prompt
Before you compute anything: which blank can you fill first, and which one only becomes available after that?
The rule is the one from the previous slide: a row or column with exactly one blank can be finished by subtraction. Scan for those first, fill them, and new ones appear. Never guess a cell from a percentage in your head.
Scan both directions every time. Students often work only across the rows, get stuck on the men's row with two blanks, and conclude the table cannot be finished. The lakes column is the way in.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 185 — Example 3.21, Table 3.5
Worked example
Fill the six blanks by subtraction, in an order where each step has only one unknown. Every subtraction below is the same sentence: the whole row or column, minus the parts you already know, leaves the part you do not.
Women on mountain peaks
Why: the women's row total minus the two known women's cells.
\[ 45 - 18 - 16 = 11 \]
Men at lakes and streams
Why: the lakes column total minus the women there.
\[ 41 - 16 = 25 \]
Now look at the men's row again. Before the last step it had two blanks and could not be finished; the lakes cell you just found leaves it with one. This is how a table unlocks: each filled cell turns some other line into a line with a single blank.
Men on the coastline
Why: now the men's row has one blank left.
\[ 55 - 25 - 14 = 16 \]
Coastline total
Why: add down the column.
\[ 18 + 16 = 34 \]
Mountain peaks total
Why: add down the column.
\[ 11 + 14 = 25 \]
Grand total
Why: add the row totals.
\[ 45 + 55 = 100 \]
Figure (svg): The hiking table with the book's given numbers in white and the six missing numbers in yellow, each tagged with the order in which it can be found: women on peaks 11 first, men at lakes 25 second, men on the coast 16 third, then the column totals 34 and 25 and the grand total 100.
The order matters less than the habit: every number came from a line with exactly one unknown, so no step depended on a guess. The completed table is the book's Table 3.6, and every later part of Example 3.21 reads from it, so an error here would travel into parts (b), (c) and (d).
Check with the other set of margins
Why: the column totals must also add to 100, and they do; that agreement is independent of the row arithmetic.
\[ 34 + 41 + 25 = 100 = 45 + 55 \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 185 — Example 3.21(a), Table 3.6
Comparison
An observational study sorted a group of people by weight and by height. The book prints only the nine cells and asks you to find every total. Fill in the blanks: row totals across, column totals down, the grand total in the corner.
Comparison matrix
| weight / height | tall | medium | short | total |
|---|---|---|---|---|
| overweight | 18 | 28 | 14 | 60 |
| typical weight | 20 | 51 | 28 | 99 |
| underweight | 12 | 25 | 9 | 46 |
| total | 50 | 104 | 51 | 205 |
Check your corner two ways before you type it. The row totals give 60 plus 99 plus 46, and the column totals give 50 plus 104 plus 51. Both come to 205. If your two routes disagree, one of your seven additions is wrong, and it is worth finding now: every later part of Try It 3.23 divides by one of these totals.
Notice that nothing in this table has to be a sample of a larger population to be read this way. The same arithmetic works for any group of people counted two ways.
Keep the finished table beside you for the rest of the lesson. Try It 3.23 returns to it in Part 5, where you will read five probabilities off it and test two of its variables for independence.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 188 — Try It 3.23(a), Table 3.11
Section
Part 2
Concept
Pick one driver at random from all 755. What is the chance that the driver has both properties, say uses a phone AND had no violation? Everyone in the sample is equally likely to be picked, so the chance is the share of the sample in that cell.
Figure (svg): The speeding table with the cell 280 (phone user AND no violation) shaded yellow, and a thick blue outline around the whole block of four cells, labelled 'denominator: all 755 drivers'.
joint probability — The probability that two events both happen, written P(A AND B). On a contingency table it is the count in the cell where the two descriptions meet, divided by the grand total.
\[ P(A\text{ AND }B) = \frac{\text{cell where A and B meet}}{\text{grand total}} \]
This is the ingredient the addition rule and the conditional formula both needed and that Section 3.3 usually made you build with the multiplication rule. Here it is just sitting in the table. That is the practical reason contingency tables are so useful.
Notice what the denominator says about the question. Dividing by 755 means the driver was chosen from everyone, with no information about them in advance. The moment a question tells you something about the driver first, the denominator will change, and that is Part 3.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 184 — Example 3.20(c)
Concept
Now ask about one variable only: what is the chance a driver uses a phone, whatever their record? You ignore the violation variable entirely, which means you add across the whole row. That row total already sits in the margin of the table, which is where the name comes from.
\[ P(A) = \frac{\text{row or column total for A}}{\text{grand total}} \]
marginal probability — The probability of one value of one variable, ignoring the other variable. On a contingency table it is a row total or a column total divided by the grand total.
A marginal is always a sum of joints. The 305 phone users are the 25 who had a violation plus the 280 who did not, so the marginal probability of phone use is the sum of the two joint probabilities in that row.
\[ \frac{305}{755} = \frac{25}{755} + \frac{280}{755} \]
That identity is also why a joint probability can never be bigger than either of its marginals: the cell is one piece of its row and one piece of its column.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 184 — Example 3.20(a) and (b)
Notation
The three kinds of probability on a table differ in only one place. Look at the denominators.
Annotate
On: \( \frac{\text{cell}}{n} \qquad \frac{\text{margin}}{n} \qquad \frac{\text{cell}}{\text{its margin}} \)
Two of the three share a numerator and two share a denominator. So when you set up a table question, decide the numerator and the denominator separately, and say each in words first: which people am I counting, and among whom?
On the speeding table the three shapes give 25 out of 755 for the joint of phone use and a violation, 305 out of 755 for the marginal of phone use, and 25 out of 70 for phone use given a violation. Each is a correct answer to its own question, and each is wrong for the other two.
The rest of the lesson is that sentence applied over and over. Among whom is the whole difficulty.
If you say the sentence and the group is everybody, the denominator is the grand total. If the group is a named part of the sample, find that part on the edge of the table and use its total.
Worked example
Using Table 3.3, find the probability that a driver is a cell phone user, and the probability that a driver had no violation in the last year.
Each question names one variable only, so each wants a margin over the grand total. The first names a row, the second a column. The book writes the first answer as the number of cell phone users over the total number in the study, which is exactly this sentence in fraction form.
Nothing about violations appears in part (a), so the violation variable is simply added over: both cells in the phone row count, the 25 with a violation and the 280 without.
Find the phone-user row total
Why: add across the row, or read the margin.
\[ 25 + 280 = 305 \]
Divide by the whole sample
Why: a driver chosen from all 755.
\[ P(\text{phone user}) = \frac{305}{755} \]
Convert to a decimal
Why: three places is plenty for a probability.
\[ \frac{305}{755} = 0.404 \]
Find the no-violation column total
Why: add down the column.
\[ 280 + 405 = 685 \]
Divide by the whole sample
Why: again every driver is a candidate.
\[ P(\text{no violation}) = \frac{685}{755} = 0.907 \]
In context: about 40 percent of the drivers in this study use a phone while driving, and about 91 percent had a clean year.
Check with the complements
Why: the other row and the other column must supply the rest of the probability, and they do.
\[ \frac{450}{755} = 0.596, \quad 0.404 + 0.596 = 1; \qquad \frac{70}{755} = 0.093, \quad 0.907 + 0.093 = 1 \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 184 — Example 3.20(a), (b)
Worked example
Find the probability that a driver had no violation in the last year AND was a cell phone user.
The word AND tells you both descriptions must hold at once, so you want the one cell where the phone-user row crosses the no-violation column. Nothing in the question restricts who is being picked, so the denominator is everyone.
Find the row
Why: uses a cell phone.
\[ \text{row: } 25, \; 280 \; (305) \]
Find the column and the crossing cell
Why: no violation; it meets the phone row at 280.
\[ \text{cell} = 280 \]
Divide by the grand total
Why: a driver picked from all 755.
\[ P(\text{no violation}\text{ AND }\text{phone}) = \frac{280}{755} \]
Convert
Why: one division.
\[ \frac{280}{755} = 0.371 \]
In words: about 37 percent of all drivers in the study are phone users with a clean year.
Compare this with part (a). The numerator dropped from 305 to 280 because a second condition was added, and only drivers meeting both survive. The denominator did not change, because the question still picks from everyone. Adding an AND can only shrink the numerator, which is why a joint is never bigger than a marginal.
Check against both marginals
Why: the joint must not exceed either of the probabilities it is carved from, and it sits below both.
\[ 0.371 \le 0.404, \qquad 0.371 \le 0.907 \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 184 — Example 3.20(c)
Fill the middle
Table 3.4 records 800 athletes by whether they stretch before exercising and whether they had an injury in the past year.
| injury | no injury | total | |
|---|---|---|---|
| stretches | 55 | 295 | 350 |
| does not stretch | 231 | 219 | 450 |
| total | 286 | 514 | 800 |
Fill in the blanks
P(\text350) = \frac800}0.4375} = ___
Why: The question names one variable, stretching, so it wants the stretching row total over everyone. That is 350 out of 800, which is 0.4375: a little under half of these athletes stretch.
If you reached for 55, you answered a different question: the share of all athletes who stretch AND were injured. A question with only one description in it wants a whole row or column, never a single cell.
Say the answer in context before moving on: about 44 percent of these 800 athletes stretch before exercising. That sentence is what a probability is for; the decimal on its own is only half the answer.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, pp. 184-185 — Try It 3.20(a)
Concept
Now the chance that a driver uses a phone OR had no violation. OR means at least one of the two, so you want everyone in the phone row together with everyone in the no-violation column.
Figure (svg): The speeding table with the phone-user row shaded blue and the no-violation column shaded orange; the cell 280 where they cross is shaded green and marked 'counted in both'. The one cell outside both, 45, is outlined in red and marked 'the only drivers left out'.
Add the row total and the column total and you have counted the 280 drivers in the crossing cell twice, once as phone users and once as clean drivers. Take them away once and every driver in the L-shape is counted exactly once. That is the addition rule, drawn.
\[ P(A\text{ OR }B) = \frac{\text{row} + \text{column} - \text{shared cell}}{\text{grand total}} \]
The figure also shows a shortcut. On a two-by-two table, the L-shape leaves out exactly one cell, here the 45 non-users with a violation. So the OR is everybody minus that one cell, which gives you a second, independent way to check every OR you compute.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 184 — Example 3.20(d)
Worked example
Find the probability that a driver is a cell phone user OR had no violation in the last year.
Two descriptions joined by OR: a row and a column. Write the addition rule first, so the overlap cannot be forgotten.
Write the rule
Why: the addition rule from Section 3.3.
\[ P(C\text{ OR }V') = P(C) + P(V') - P(C\text{ AND }V') \]
Read the three pieces off the table
Why: row total, column total, crossing cell, all over 755.
\[ = \frac{305}{755} + \frac{685}{755} - \frac{280}{755} \]
Combine over the common denominator
Why: add the two margins, subtract the cell.
\[ = \frac{305 + 685 - 280}{755} \]
Do the arithmetic
Why: 990 minus 280.
\[ = \frac{710}{755} \]
Convert
Why: one division.
\[ \frac{710}{755} = 0.940 \]
In context: 94 percent of the drivers either use a phone, or had a clean year, or both. Here C stands for phone user and V prime for no violation.
The book writes this exactly as the addition rule with every probability read off the table: the two marginals in brackets, minus the joint. Nothing had to be built from a conditional, which is the whole advantage of having the table.
Check by counting who is left out
Why: only the 45 non-users with a violation are outside both; everyone else is inside.
\[ 755 - 45 = 710 \quad\checkmark \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 184 — Example 3.20(d)
Worked example
Using the completed hiking table, find the probability that a hiker is a woman or prefers hiking on mountain peaks. Let F be being a woman and P be preferring peaks.
The same L-shape as before, but on a two-by-three table: the women's row and the peaks column, crossing at the 11 women who prefer peaks.
The row: women
Why: row total over the grand total.
\[ P(F) = \frac{45}{100} \]
The column: mountain peaks
Why: column total over the grand total.
\[ P(P) = \frac{25}{100} \]
The crossing cell
Why: women who prefer peaks.
\[ P(F\text{ AND }P) = \frac{11}{100} \]
Apply the addition rule
Why: subtract the shared cell once.
\[ P(F\text{ OR }P) = \frac{45}{100} + \frac{25}{100} - \frac{11}{100} \]
Simplify
Why: 45 plus 25 is 70; 70 minus 11 is 59.
\[ P(F\text{ OR }P) = \frac{59}{100} = 0.59 \]
In context: 59 of the 100 hikers are women, peak lovers, or both.
On a table wider than two columns the complement check needs a little more care. The L-shape now leaves out two cells, not one: the men who prefer the coast and the men who prefer lakes. Everyone outside the L is a man who does not prefer peaks, so that is the group to subtract.
Check by counting who is left out
Why: on this wider table the L misses the men who prefer the coast or the lakes: 16 plus 25.
\[ 100 - (16 + 25) = 59 \quad\checkmark \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 186 — Example 3.21(d)
Trap
Asked for the chance of phone user OR no violation, a common first line:
\[ \frac{305}{755} + \frac{685}{755} \]
\[ = \frac{990}{755} = 1.311 \]
Wrong. A probability above 1 is impossible, and that is your alarm.
The error is natural because OR sounds like plus. But the 280 phone users with clean records were counted in the row and again in the column.
Subtract the shared cell once, so each driver is counted once:
\[ \frac{305 + 685 - 280}{755} \]
\[ = \frac{710}{755} = 0.940 \]
Adding without subtracting is only correct when the row and column cannot share anyone, that is, when the events are mutually exclusive. A phone row and a violation column always cross, so on a two-way table that almost never happens.
One more test that catches it every time: the answer to an OR can never be larger than 1, and it can never be larger than the sum of its two parts. If the arithmetic gives more than 1, the overlap is still in there twice.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 184 — Example 3.20(d)
Estimation
A table has a row total of 305 and a column total of 70, out of 755. You do not know the cell where they cross.
Predict first
What is the largest the crossing cell could possibly be?
Correct: 70
Why: The cell is part of its row and part of its column, so it can be no bigger than the smaller of the two totals. At most all 70 people in the column are also in the row. So the joint probability can be at most 70 out of 755, the smaller of the two marginals.
This gives a quick sanity check you can apply without a calculator. A joint probability bigger than either of its marginal probabilities is always an error, usually a sign that a total was used where a cell was wanted.
\[ P(A\text{ AND }B) \le \min\{P(A), P(B)\} \]
In the real table the cell is 25, well under the ceiling of 70.
There is a floor as well. The row and column together cannot hold more than 755 people, so the cell must be at least 305 plus 70 minus 755, which is negative here, so the floor is simply zero. On tables where the two margins are large, that floor can be well above zero, and it pins the cell from below.
Sorting
Each question below is about the stretching table. Decide which kind of probability it asks for before you think about any numbers.
Sort into buckets
Sort each question by the kind of probability it asks for.
Listen for the phrase that names the group. Of all athletes means the whole table. Of the athletes who stretch, or among injured athletes, means one row or one column, and that is a conditional even though the word given never appears.
Then count the conditions. A joint names two of them and counts among everyone; a marginal names one and counts among everyone. If you ever find a question naming two conditions where one of them is the group, that is the conditional.
Section
Part 3
Concept
Now: what is the probability that a driver is a phone user, given that the driver had a violation? The given tells you the driver is one of the 70 in the violation column. Everyone else, all 685 clean drivers, is no longer a possibility.
Figure (svg): The speeding table with every column except 'violation' dimmed. The violation column, with 25 phone users and 45 non-users totalling 70, is outlined in yellow and labelled 'the new sample space: 70 drivers'.
Section 3.1 called this reducing the sample space. On a table it is literal: the given condition picks out one row or one column, and that row or column becomes the whole world. The answer is the share of that world that also meets the other condition.
\[ P(\text{phone} \mid \text{violation}) = \frac{25}{70} \]
Check that this agrees with the formula from Section 3.3. The joint is 25 out of 755 and the probability of a violation is 70 out of 755. Divide one by the other and the 755s cancel, leaving 25 over 70. The table just skips the step.
\[ \frac{25/755}{70/755} = \frac{25}{70} \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 184 — Example 3.20(e): the sample space is reduced
Notation
On a table of counts, the conditional formula can be written with counts instead of probabilities. The letter n here means the number of people in the table who fit a description.
Annotate
On: \( P(A \mid B) = \frac{n(A\text{ AND }B)}{n(B)} \)
The bar does all the work. Read everything to the right of it as the phrase among those who, and everything to the left as the thing you are counting. The phone user given violation becomes: among those who had a violation, count the phone users.
A quick self-test: which total goes on the bottom of the probability of a violation given phone use? The phone row total, 305, because phone use is to the right of the bar.
Concept
A two-way table always hides two families of conditional probabilities. Condition on the rows and you compare columns within each row; condition on the columns and you compare rows within each column. Both are legitimate, and they answer different questions about the same people.
| read along | denominator | example from Table 3.3 | answers |
|---|---|---|---|
| a row | that row's total | 25/305 = 0.082 | how often do phone users get a violation? |
| a column | that column's total | 25/70 = 0.357 | how many violators use a phone? |
Which direction you need depends on which variable you think of as the cause or the group of interest. A safety researcher asking whether phones make speeding worse wants violation rates within each phone group, reading along the rows. An insurer who only sees drivers after a violation sees the column.
\[ P(V \mid C) = \frac{25}{305} \qquad \text{vs} \qquad P(C \mid V) = \frac{25}{70} \]
The two numbers share a numerator and are almost never equal, because the row and the column have different totals. Swapping them is the single most expensive mistake in applied probability, and the real-world bridge at the end of Part 5 shows it in a news story.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 184 — Example 3.20(e) against the reverse conditional
Worked example
Find the probability that a driver is a cell phone user given that the driver had a violation, and the probability that a driver had no violation given that the driver was not a phone user.
Each has the word given, so each keeps only one row or column. Find the kept group first, then the cell inside it. The book adds a note to each answer saying the sample space is reduced, first to the drivers who had a violation and then to the drivers who were not phone users. That note is the denominator.
Part (e): keep the violation column
Why: given a violation: 70 drivers.
\[ n(\text{violation}) = 70 \]
Find the phone users inside it
Why: the crossing cell.
\[ n(\text{phone}\text{ AND }\text{violation}) = 25 \]
Divide by the kept total
Why: a share of the 70.
\[ P(\text{phone} \mid \text{violation}) = \frac{25}{70} = 0.357 \]
Part (f): keep the non-user row
Why: given not a phone user: 450 drivers.
\[ n(\text{no phone}) = 450 \]
Find the clean drivers inside it
Why: the crossing cell.
\[ n(\text{no violation}\text{ AND }\text{no phone}) = 405 \]
Divide by the kept total
Why: a share of the 450.
\[ P(\text{no violation} \mid \text{no phone}) = \frac{405}{450} = 0.9 \]
In context: about 36 percent of the drivers who had a violation were phone users, and 90 percent of non-users had a clean year.
Notice that part (e) conditions on a column and part (f) on a row. The table does not care which: the given condition can be a row or a column, and in either case its own total is the one you divide by. Only the direction of the bar decides.
Check with the complements inside each group
Why: the rest of each kept group must make up the difference: 45 of 70 violators were non-users, and 45 of 450 non-users had a violation.
\[ \frac{25}{70} + \frac{45}{70} = 1, \qquad \frac{405}{450} + \frac{45}{450} = 1 \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 184 — Example 3.20(e), (f)
Picture it
Take the same 25 drivers, the phone users with a violation, and divide them by three different totals. You get three different probabilities, and each one is a correct answer to a different question.
Figure (svg): A bar chart of three probabilities that all have numerator 25: 25 over 755 is 0.033, 25 over 305 is 0.082, and 25 over 70 is 0.357. The bars grow as the denominator shrinks.
Among all 755 drivers, they are a 3 percent sliver: that is the joint. Among the 305 phone users, they are 8 percent: that is the chance of a violation given phone use. Among the 70 violators, they are 36 percent: that is the chance of phone use given a violation.
So a probability quoted without its group is almost meaningless. Whenever you read a percentage, in a textbook or a newspaper, ask the question the table forces on you: a percentage of whom?
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 184 — Table 3.3
Worked example
Using the stretching table, find the probability that an athlete stretches before exercising, given no injury in the last year.
The given is no injury, so keep the no-injury column. You are counting stretchers inside it. The book writes this with a vertical bar and no word given at all, so read the bar aloud as among athletes with no injury before you choose a total.
Keep the given column
Why: no injury: 514 athletes.
\[ n(\text{no injury}) = 514 \]
Find the stretchers inside it
Why: the crossing cell.
\[ n(\text{stretches}\text{ AND }\text{no injury}) = 295 \]
Divide by the kept total
Why: a share of the 514.
\[ P(\text{stretches} \mid \text{no injury}) = \frac{295}{514} \]
Convert
Why: one division.
\[ \frac{295}{514} = 0.574 \]
In context: about 57 percent of the uninjured athletes stretch, compared with about 44 percent of all athletes. Stretchers are over-represented among the uninjured.
That comparison is already an independence test in miniature. If stretching had nothing to do with injury, the uninjured athletes would stretch at the same rate as everyone. They do not, and Part 4 will make that argument properly.
Check through the formula with probabilities
Why: the joint over the marginal must give the same answer once the 800s cancel.
\[ \frac{295/800}{514/800} = \frac{0.36875}{0.6425} = 0.574 \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 185 — Try It 3.20(b)
Worked example
Find the probability that a hiker is a man given that the person prefers hiking near lakes and streams. Let M be being a man and L be preferring lakes. The book asks three questions on the way, and they are the three decisions every conditional needs.
Spot the conditional
Why: the word given tells you this is a conditional, with L to the right of the bar.
\[ P(M \mid L) \]
Name the sample space
Why: not all 100 hikers, only the 41 who prefer lakes and streams.
\[ n(L) = 41 \]
Find the men inside it
Why: the men's row meets the lakes column.
\[ n(M\text{ AND }L) = 25 \]
Divide
Why: a share of the 41.
\[ P(M \mid L) = \frac{25}{41} = 0.610 \]
In context: 61 percent of the hikers who prefer lakes and streams are men. Men are 55 percent of the sample, so lakes lean slightly male.
The book's third question is the one to keep asking yourself: is the sample space all 100 hikers? It is not. A conditional always answers a question about a smaller group, and naming that group out loud is what stops you dividing by 100 out of habit.
Check with the women in the same column
Why: the other cell in the column must supply the rest of the 41.
\[ \frac{16}{41} + \frac{25}{41} = \frac{41}{41} = 1 \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, pp. 185-186 — Example 3.21(c)
Trap
Asked for the chance of phone use given a violation, a common line:
\[ P(\text{phone} \mid \text{viol.}) = \frac{25}{305} \]
\[ = 0.082 \]
Wrong. 305 is the phone row, but phone use is not what you were given.
The mistake comes from dividing by the total of the event named first. The bar, not the word order, decides.
The given event is the violation, to the right of the bar, so divide by the violation column:
\[ P(\text{phone} \mid \text{viol.}) = \frac{25}{70} \]
\[ = 0.357 \]
The wrong fraction is not meaningless: 25 over 305 is the chance of a violation given phone use. Swapping the two events swaps the denominator, and the two answers differ by a factor of four here.
A good defence is to write the probability in words before writing a fraction: the chance of phone use among drivers with a violation. The words among drivers with a violation name the column, and the column total goes underneath.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 184 — Example 3.20(e)
Matching
All four questions use the speeding table, and all four answers are one number over another. Match them. Two of them share a numerator, so look hard at the denominators.
Match the pairs
Why: The first three share the cell 25 and differ only in the group: phone users, violators, or everyone. The fourth keeps the non-user row, 450, and counts the clean drivers in it, 405. In every conditional the denominator is the total of the event after the word given.
If you matched the first two the wrong way round, reread the bar as among those who. Violation given phone user is among phone users, so it is over 305.
It helps to notice what each answer is about. Twenty-five out of 305 is a fact about phone users: 8 percent of them had a violation. Twenty-five out of 70 is a fact about violators: 36 percent of them use a phone. Both are true of the same table, and neither can be swapped for the other.
Fill the middle
A random sample of 200 cyclists was asked which route they prefer. Let O be older and H be preferring the hilly path.
| age group | lake | hilly | wooded | total |
|---|---|---|---|---|
| younger | 45 | 38 | 27 | 110 |
| older | 26 | 52 | 12 | 90 |
| total | 71 | 90 | 39 | 200 |
The question says out of the older group, which is a conditional in disguise: the older row is the sample space.
Fill in the blanks
P(H \mid O) = \frac52}90} = 0.578
Why: Keep the older row, 90 cyclists, and count the ones who prefer the hilly path, 52. So 52 out of 90, about 0.578: well over half of the older cyclists prefer hills.
A common slip is 52 out of 200, which is the joint probability of older AND hilly. The phrase out of the older group is doing the same job as the word given.
Keep this number: 0.578. Part (b) of the same Try It asks whether being older and preferring hills are independent, and this conditional is half of the answer.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 186 — Try It 3.21(a), Table 3.7
Error analysis
Someone answered four questions about the stretching table. Two of the answers are right and two are wrong. Tap each piece to see which, and why.
Annotate
On: \( \frac{286}{800} \quad \frac{55}{286} \quad \frac{55}{800} \quad \frac{231}{286} \)
Both errors are the same error: the denominator came from the event on the left of the bar instead of the right. That is the single most common mistake in this section, and the fix is always to say the group out loud before you divide.
Notice also that the two wrong answers would pass a quick sanity check, since both are between 0 and 1. Only reading the question catches them. The one number check that does help: the two correct injury rates, 0.157 and 0.513, sit on either side of the overall rate, 0.3575, as a pair of row rates always must.
Section
Part 4
Concept
Section 3.2 said A and B are independent when knowing B does not change the chance of A. On a table, knowing B means keeping B's row or column. So independence asks: is the share of A inside B's group the same as the share of A in the whole table?
\[ P(A \mid B) = P(A) \]
\[ \frac{n(A\text{ AND }B)}{n(B)} = \frac{n(A)}{n} \]
Think back to the mosaic of the 755 drivers. Independence would mean the red violation band is exactly the same height in both columns, because a driver's column would tell you nothing about the violation. Any difference in height is a dependence.
In the stretching table, the two rows split very differently: about one in six stretchers was injured, but about one in two non-stretchers. The row a person is in changes the injury picture a lot, so those variables are dependent. In the speeding table the two rows split almost alike.
There are three equivalent ways to run the test, and the book uses two of them. Compare a conditional with the matching marginal; compare two conditionals from different rows; or compare the joint with the product of the two marginals. If one of those comparisons shows equality, all of them do.
\[ P(A\text{ AND }B) = P(A)\,P(B) \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 185 — Example 3.21(b)
Notation
Example 3.21(b) uses the product form of the test. Here is what each piece is, read off the table.
Annotate
On: \( \frac{\text{cell}}{n} \;\overset{?}{=}\; \frac{\text{row total}}{n}\cdot\frac{\text{column total}}{n} \)
Multiply both sides by n and the test becomes a comparison of counts: the cell against the row total times the column total divided by n. That second number has a name, the expected count, and you will meet it at the end of this part and again in Chapter 11.
Why does the product mean independence? The multiplication rule says the joint is the probability of B times the probability of A given B. Independence lets you replace the conditional by the plain probability of A, and what is left is the product of the two marginals.
Worked example
Are the events being a woman, F, and preferring the coastline, C, independent? The book's method: compare the joint with the product of the marginals.
The product is what the multiplication rule would give if knowing a hiker's sex told you nothing about where they like to hike. So the test asks whether the real joint matches that no-information prediction. Three numbers, all read from the completed table.
Find the joint
Why: the women-coast cell over all 100.
\[ P(F\text{ AND }C) = \frac{18}{100} = 0.18 \]
Find the two marginals
Why: the women's row total and the coast column total.
\[ P(F) = \frac{45}{100} = 0.45, \qquad P(C) = \frac{34}{100} = 0.34 \]
Multiply the marginals
Why: what the joint would be under independence.
\[ P(F)\,P(C) = (0.45)(0.34) = 0.153 \]
Compare
Why: the two numbers are not the same.
\[ 0.18 \ne 0.153 \]
So F and C are not independent. In context: in this sample, women are more likely than men to prefer the coastline, 40 percent against 29 percent. The joint is bigger than the product, which means women and the coast turn up together more often than chance pairing would produce.
Figure (svg): A bar chart of the chance of preferring the coastline: 0.400 among the 45 women and 0.291 among the 55 men, with a dashed line at 0.34 for all 100 hikers.
Check with the conditional form
Why: the chance of the coast among women must differ from the chance among everyone, and it does; the two tests agree, as they must.
\[ P(C \mid F) = \frac{18}{45} = 0.400 \ne 0.34 = P(C) \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 185 — Example 3.21(b)
Worked example
From the homework set for this section: using the stretching table, decide whether stretching and injury are independent. This time use the conditional form, comparing the injury rate among stretchers with the injury rate among everybody.
The conditional form is usually the easier one to explain to someone else, because both numbers are rates you can say in a sentence: the share of stretchers who were injured, and the share of all athletes who were injured.
Injury rate among stretchers
Why: keep the stretching row, 350.
\[ P(I \mid S) = \frac{55}{350} = 0.157 \]
Injury rate among everybody
Why: the injury column over 800.
\[ P(I) = \frac{286}{800} = 0.3575 \]
Compare
Why: far apart.
\[ 0.157 \ne 0.3575 \]
Name the conclusion
Why: a conditional that differs from its marginal means dependence.
\[ \text{stretching and injury are dependent} \]
Figure (svg): A bar chart of the chance of injury: 0.157 for the 350 athletes who stretch and 0.513 for the 450 who do not, with a dashed yellow line at 0.3575 for all 800 athletes.
In context: in this sample, athletes who stretched were injured at less than half the rate of all athletes. That is an association in these 800 athletes. It is not by itself proof that stretching prevents injury: the athletes chose whether to stretch, and careful athletes may differ in other ways too.
Check with the other row
Why: if the variables were independent, the non-stretchers would also sit at 0.3575; instead they are far above it, balancing the stretchers.
\[ P(I \mid S') = \frac{231}{450} = 0.513 \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 184 — Table 3.4 and the section's homework seeds
Trap
Looking at the stretching table, someone argues:
\[ 55 \text{ vs } 231 \]
Four times as many injuries among non-stretchers, so non-stretchers are four times as likely to be injured.
Wrong. The two rows are different sizes, 350 and 450. Counts are not rates.
Turn each count into a rate within its own row first:
\[ \frac{55}{350} = 0.157 \]
\[ \frac{231}{450} = 0.513 \]
Non-stretchers are about 3.3 times as likely to be injured, not four. Here the gap shrank; with rows of very different sizes a raw-count comparison can even point the wrong way. Always compare shares of a group, never counts from groups of different sizes.
The same trap appears in news stories that report more accidents involving young drivers than old ones. Young drivers may simply drive more miles; only a rate per driver, or per mile, can be compared.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 184 — Table 3.4
Worked example
Are the events being older, O, and preferring the hilly path, H, independent? Use the answer to part (a), the chance of hills among older cyclists.
This table has three route columns, but the question is about one of them, so treat hilly against not hilly. The other two columns simply join the not-hilly side; you never need them separately.
The conditional, from part (a)
Why: the older row, 90.
\[ P(H \mid O) = \frac{52}{90} = 0.578 \]
The matching marginal
Why: the hilly column over all 200.
\[ P(H) = \frac{90}{200} = 0.45 \]
Compare
Why: not equal.
\[ 0.578 \ne 0.45 \]
Conclude
Why: the older group's preference differs from everyone's.
\[ O \text{ and } H \text{ are not independent} \]
Figure (svg): Three horizontal bars, each split into lake, hilly and wooded shares. Younger cyclists: 0.41, 0.35, 0.25. Older cyclists: 0.29, 0.58, 0.13. All 200 cyclists: 0.36, 0.45, 0.20.
In context: older cyclists prefer the hilly path noticeably more often than cyclists as a whole, 58 percent against 45 percent. The bar picture shows the same thing: the older bar's hilly segment is far wider than the all-cyclists bar's.
Check with the product form
Why: the joint is 52 out of 200, while the product of the marginals is 0.45 times 0.45; the two forms agree that there is dependence.
\[ P(O\text{ AND }H) = 0.26 \ne 0.2025 = (0.45)(0.45) \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 186 — Try It 3.21(b)
Concept
Here is a different way to ask the same question. Keep every margin of the stretching table exactly as it is. If stretching made no difference to injury, how many injured stretchers would you expect?
Under independence, the injury rate inside the stretching row would equal the injury rate overall, 286 out of 800. Apply that rate to the 350 stretchers.
\[ 350 \times \frac{286}{800} \]
\[ = \frac{350 \times 286}{800} \]
\[ = \frac{100100}{800} = 125.1 \]
expected count — The count a cell would hold if the two variables were independent, keeping the table's margins fixed: the row total times the column total, divided by the grand total.
\[ \text{expected} = \frac{\text{row total} \times \text{column total}}{\text{grand total}} \]
It does not need to be a whole number: it is a long-run average, not a head count. The formula is the product test multiplied through by n, so a cell equal to its expected count is exactly the independence condition.
Read the three lines above as a story. Out of all 800 athletes, 286 were injured, a rate of about 36 percent. If stretchers were injured at the same rate as everyone, about 36 percent of the 350 stretchers would be injured, which is about 125 of them. The real table shows 55.
Concept
Compute the expected count for every cell of the stretching table and compare it with what was observed. This extends the homework seed for this section.
Each line uses the same recipe: the cell's row total times its column total, over 800. Only the first one really needs computing; the other three follow by subtraction from the margins, but computing all four gives you a check for free.
Stretches and injured
Why: row 350, column 286.
\[ \frac{350 \times 286}{800} = 125.1 \]
Stretches, no injury
Why: row 350, column 514.
\[ \frac{350 \times 514}{800} = 224.9 \]
No stretch, injured
Why: row 450, column 286.
\[ \frac{450 \times 286}{800} = 160.9 \]
No stretch, no injury
Why: row 450, column 514.
\[ \frac{450 \times 514}{800} = 289.1 \]
Figure (svg): Two small tables side by side. Left, observed counts: stretches 55 injured and 295 not; does not stretch 231 and 219. Right, the counts independence would predict with the same margins: 125.1 and 224.9, then 160.9 and 289.1. The cell 55 against 125.1 is highlighted.
The observed 55 injured stretchers is less than half the 125 that independence predicts, and the non-stretchers show the opposite gap, 231 against 161. A difference that large, in a sample of 800, is very unlikely to be luck. Chapter 11 turns exactly these gaps into a formal test.
Check that the expected table keeps the margins
Why: the expected counts must add to the same row totals as the real table, and they do.
\[ 125.1 + 224.9 = 350, \qquad 160.9 + 289.1 = 450 \]
Tweak it
Keep the stretching table's margins fixed: 350 stretchers, 450 non-stretchers, 286 injured. Only the number of injured stretchers, k, is free, because one cell decides the rest. The plot shows the injury rate in each row: stretchers on the left half, non-stretchers on the right half.
Parameter explorer
Slide k. At the real value, 55, the two rates are far apart. Find the value of k that makes the two rates level, and compare it with the expected count from the previous slide.
\[ P(I \mid S) = \frac{{k}}{350} \]
The level point is where the table would show independence, at about 125. Every other value of k makes the rows differ, in one direction or the other. The real table sits a long way from level.
Notice how lopsided the slider range is. The cell can run from 0 to 286, but only one value in all that range gives independence. Push k to either end and you get tables where stretching almost guarantees, or almost rules out, an injury.
This is why independence is a single point and dependence is everything else. In a real sample it is almost never hit exactly, which is the subject of the next slide.
Intuition
Look again at the speeding table. The violation rate is 25 out of 305 for phone users and 70 out of 755 overall.
\[ P(V \mid C) = \frac{25}{305} = 0.082, \qquad P(V) = \frac{70}{755} = 0.093 \]
Strictly, these are not equal, so by the definition the two events are not independent in this sample. But the gap is about one percentage point. Compare that with the stretching table, where the gap was twenty.
\[ 0.093 - 0.082 = 0.011 \qquad \text{vs} \qquad 0.3575 - 0.157 = 0.2 \]
Even if phone use truly had no effect on speeding, a random sample of 755 drivers would almost never produce rates that match to three decimal places. Chance alone moves them a little. So in this chapter, not equal is the textbook's answer, but an honest one-sentence conclusion also says how big the difference is.
Deciding whether a difference is too big to be chance is what hypothesis tests are for. Chapter 11's test of independence answers exactly this question for a contingency table.
Intuition
Every independence comparison in this lesson had the same shape: one row's rate above the overall rate, the other row's rate below it. That is not luck. The overall rate is an average of the row rates, weighted by how big each row is.
\[ \frac{286}{800} = \frac{350}{800}\cdot\frac{55}{350} + \frac{450}{800}\cdot\frac{231}{450} \]
Each term on the right is a row's share of the athletes times that row's injury rate. Cancel the 350 and the 450 and you are left with 55 over 800 plus 231 over 800, which is 286 over 800. So the identity is just the column total written as the sum of its two cells.
\[ 0.3575 = (0.4375)(0.157) + (0.5625)(0.513) \]
An average of two numbers lies between them, so the overall rate is always trapped between the row rates, closer to the rate of the bigger row. That gives you a free check on every conditional you compute: if both row rates come out above the overall rate, one of them is wrong.
It also explains why the two tests in Part 4 always agree. If one row's rate equals the overall rate, the average forces the other row's rate to equal it too, and the rows split in the same proportions.
Counterexample
Every table so far has shown dependence. Show that independence is possible by building one. Choose round numbers so that you can check the rates in your head.
Discussion prompt
Make a two-by-two table of 200 people, sorted by whether they drink coffee and whether they sleep badly, in which the two are exactly independent. Then show that it passes the test.
Any table whose rows are in proportion works. The quick recipe: choose the margins, then set each cell to its expected count, row total times column total over the grand total.
You can also build it column-wise: make each column split between coffee and no coffee in the same proportion, three fifths to two fifths. Row proportions and column proportions match at the same time, which is why the independence test works in either direction.
Check your table with the product form too. The joint of coffee AND bad sleep is 30 out of 200, which is 0.15, and the product of the two marginals is 0.6 times 0.25, also 0.15. Building a table that passes shows you exactly what every failing table is failing at: its rows do not split in the same proportions.
Section
Part 5
Concept
Sometimes you are not given counts at all, only probabilities and conditional probabilities. You can still build a contingency table: put a joint probability in each cell, and the grand total becomes 1 instead of a sample size.
Each cell comes from the multiplication rule. The chance of a row condition AND a column condition is the chance of the column times the chance of the row given the column.
\[ P(\text{door 1}\text{ AND }\text{caught}) = P(\text{door 1})\,P(\text{caught} \mid \text{door 1}) \]
Once the cells are in, everything else works exactly as with counts. Margins are sums of cells. The corner is 1, which gives the same kind of check as before. A conditional is still a cell over its own margin, because the conditional formula divides probabilities just as happily as counts.
You will meet this again in Section 3.5, where the same numbers are drawn as a tree. The tree and the table are two views of the same six probabilities: the tree shows how each one was built, the table shows how they add up.
The next two examples fill one of these tables for a mouse choosing among three doors, then read two answers off it.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, pp. 186-187 — Example 3.22, Table 3.8
Worked example
Muddy Mouse picks one of three doors, each with probability one third. At door one Alissa the cat catches him with probability one fifth, at door two one quarter, at door three one half. Complete the probability table.
The catch probabilities are conditionals: one fifth is the chance of being caught given door one. The table wants joints. The tree turns one into the other: follow a path, multiply along it, and the product lands in a cell.
Figure (svg): A tree. From the start, three branches of probability 1/3 lead to door 1, door 2 and door 3. From door 1, caught 1/5 and not caught 4/5; from door 2, caught 1/4 and not 3/4; from door 3, caught 1/2 and not 1/2. The six path ends read 1/15, 4/15, 1/12, 3/12, 1/6 and 1/6.
Door 1 cells
Why: one third times the chance at door 1.
\[ \tfrac13 \cdot \tfrac15 = \tfrac{1}{15}, \qquad \tfrac13 \cdot \tfrac45 = \tfrac{4}{15} \]
Door 2 cells
Why: one third times the chance at door 2.
\[ \tfrac13 \cdot \tfrac14 = \tfrac{1}{12}, \qquad \tfrac13 \cdot \tfrac34 = \tfrac{3}{12} \]
Door 3 cells
Why: one third times one half, both ways.
\[ \tfrac13 \cdot \tfrac12 = \tfrac{1}{6}, \qquad \tfrac13 \cdot \tfrac12 = \tfrac{1}{6} \]
Caught row total
Why: put the three over a common denominator of 60.
\[ \tfrac{4}{60} + \tfrac{5}{60} + \tfrac{10}{60} = \tfrac{19}{60} \]
Not-caught row total
Why: the same, with the other three cells.
\[ \tfrac{16}{60} + \tfrac{15}{60} + \tfrac{10}{60} = \tfrac{41}{60} \]
The book prints the column totals as 5/15, 4/12 and 2/6. Reduce them: every one is one third, as it must be, since each door is chosen with probability one third. That is already a check on the six cells: each column adds back to the chance of choosing its door.
Adding the rows needs a common denominator. Fifteenths, twelfths and sixths all go into sixtieths, so rewrite each cell in sixtieths first; the addition is then just adding numerators.
Verify the corner is 1
Why: the row totals and the column totals must both reach 1.
\[ \tfrac{19}{60} + \tfrac{41}{60} = 1 = \tfrac13 + \tfrac13 + \tfrac13 \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 187 — Example 3.22(a), Table 3.9
Worked example
Part (b): what is the probability that Alissa does not catch Muddy? Part (c): given that Muddy is caught, what is the probability that he chose door one OR door two?
Part (b) is a marginal
Why: the not-caught row total over the corner, which is 1.
\[ P(\text{not caught}) = \tfrac{41}{60} = 0.683 \]
Because the corner is 1, dividing a margin by the grand total changes nothing: on a probability table the margins already are the marginal probabilities. That is one convenience of building the table from probabilities.
Figure (svg): A unit square split into three equal columns for the three doors. Each column is shaded from the bottom to the chance of being caught at that door: one fifth, one quarter and one half. The shaded area totals 19/60.
Part (c) combines an OR with a given, so do the given first. Being caught keeps only the caught row, total 19 sixtieths. Inside that row, doors one or two means two of the three cells. Because Muddy uses one door, those two cells cannot overlap, and the OR is a plain sum.
Part (c): keep the caught row
Why: the given is being caught, probability 19/60.
\[ P(\text{caught}) = \tfrac{19}{60} \]
Numerator: doors one or two, inside the caught row
Why: two cells that cannot overlap, since he uses one door.
\[ \tfrac{1}{15} + \tfrac{1}{12} = \tfrac{4}{60} + \tfrac{5}{60} = \tfrac{9}{60} \]
Divide by the given row
Why: the sixtieths cancel.
\[ P(D_1\text{ OR }D_2 \mid \text{caught}) = \frac{9/60}{19/60} = \frac{9}{19} \]
Convert
Why: one division.
\[ \frac{9}{19} = 0.474 \]
In context: although doors one and two are two thirds of Muddy's choices, they account for under half of his captures, because door three is so dangerous.
Check with door three
Why: the rest of the caught row must be door three, and the two shares must add to 1.
\[ P(D_3 \mid \text{caught}) = \frac{10/60}{19/60} = \frac{10}{19}, \qquad \frac{9}{19} + \frac{10}{19} = 1 \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 187 — Example 3.22(b), (c)
Prediction
Anna can afford only one car. She buys car A with probability 0.25 and car B with probability 0.65.
Predict first
What is the probability that Anna buys car A AND car B?
Correct: 0
Why: She can afford only one car, so buying both is impossible: the events are mutually exclusive and their joint probability is zero. Multiplying 0.25 by 0.65 would assume independence, which is the opposite situation. With the AND at zero, the OR is just the sum, 0.25 plus 0.65, which is 0.9.
\[ P(A\text{ AND }B) = 0, \qquad P(A\text{ OR }B) = 0.25 + 0.65 - 0 = 0.9 \]
In table terms, the cell for A AND B is empty, so the OR has no overlap to subtract. The missing 0.1 is the chance that she buys neither car, which the problem leaves unsaid; a full table would need a column for it.
This is the one situation where adding two probabilities without subtracting is right: when the crossing cell is known to be empty. Notice also that A and B are far from independent. Knowing she bought car A tells you for certain she did not buy car B.
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 187 — Try It 3.22
Worked example
Table 3.10 gives United States crime rates per 100,000 inhabitants for four years and four kinds of crime. The book says to total every row and column; the grand total is 4,520.7.
| year | robbery | burglary | vandalism | vehicle | total |
|---|---|---|---|---|---|
| 1 | 145.7 | 732.1 | 29.7 | 314.7 | 1222.2 |
| 2 | 133.1 | 717.7 | 29.1 | 259.2 | 1139.1 |
| 3 | 119.3 | 701 | 27.7 | 239.1 | 1087.1 |
| 4 | 113.7 | 702.2 | 26.8 | 229.6 | 1072.3 |
| total | 511.8 | 2853 | 113.3 | 1042.6 | 4520.7 |
Figure (svg): Four stacked horizontal bars, one per year, each split into robbery, burglary, vandalism and vehicle rates per 100,000 people. Year totals are 1222.2, 1139.1, 1087.1 and 1072.3; burglary is by far the widest segment every year and vandalism the thinnest.
These entries are rates, not people, so a probability here means a share of all the crime counted in the table. The arithmetic is exactly the same as with counts.
Be honest about what such a probability means. Picture a single reported crime drawn at random from everything tallied in the table: part (a) is the chance that it was a robbery in year 2. It says nothing about the chance that a particular person is robbed.
Part (a): year 2 AND robbery
Why: one cell over the grand total.
\[ \frac{133.1}{4520.7} = 0.0294 \]
Part (b): year 3 AND burglary
Why: one cell over the grand total.
\[ \frac{701}{4520.7} = 0.1551 \]
Check the grand total both ways
Why: the four row totals and the four column totals must each reach 4,520.7, and they do.
\[ 1222.2 + 1139.1 + 1087.1 + 1072.3 = 4520.7 \]
\[ 511.8 + 2853 + 113.3 + 1042.6 = 4520.7 \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 188 — Example 3.23(a), (b), Table 3.10
Worked example
Part (c) asks for year 3 OR burglary; part (d) for year 4 given vandalism; part (e) for vehicle theft given year 1. One OR and two conditionals, one conditioning on a column and one on a row: the whole lesson in three lines.
Part (c): row plus column minus the crossing cell
Why: year 3 row, burglary column, crossing at 701.
\[ \frac{1087.1 + 2853 - 701}{4520.7} \]
Simplify the numerator
Why: 3940.1 minus 701.
\[ = \frac{3239.1}{4520.7} = 0.7165 \]
Part (d): keep the vandalism column
Why: its total is 113.3; year 4's share of it.
\[ P(\text{year 4} \mid \text{vandalism}) = \frac{26.8}{113.3} = 0.2365 \]
Part (e): keep the year 1 row
Why: its total is 1222.2; the vehicle share of it.
\[ P(\text{vehicle} \mid \text{year 1}) = \frac{314.7}{1222.2} = 0.2575 \]
In context: in year 1, about a quarter of the crime counted here was vehicle theft. Of all the vandalism across the four years, just under a quarter came in year 4. All five of the book's printed answers check to four places.
Part (c) is large because burglary alone is 2853 of the 4520.7, about 63 percent of the table. Any OR that includes the burglary column starts from there, which the stacked bars made visible before you did any arithmetic.
Check part (c) by the complement
Why: outside the L are the non-burglary crimes of years 1, 2 and 4: each row total minus its burglary cell, 490.1, 421.4 and 370.1.
\[ 490.1 + 421.4 + 370.1 = 1281.6 \]
\[ 1 - \frac{1281.6}{4520.7} = 0.7165 \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, p. 188 — Example 3.23(c), (d), (e)
Worked example
Using the weight-and-height table you totalled earlier, with 205 people, find the chances of tall, of overweight AND tall, of tall given overweight, of overweight given tall, and of tall AND underweight. Then decide whether overweight and tall are independent.
Before each line, decide which of the three shapes it is: a margin over 205, a cell over 205, or a cell over its own row or column total. Below, ow stands for overweight and uw for underweight.
(b) Tall: a column over everyone
Why: 50 tall people.
\[ P(\text{tall}) = \frac{50}{205} = 0.244 \]
(c) Overweight AND tall: a cell over everyone
Why: the crossing cell is 18.
\[ P(\text{ow}\text{ AND }\text{tall}) = \frac{18}{205} = 0.088 \]
(d) Tall given overweight: keep the overweight row
Why: 60 people.
\[ P(\text{tall} \mid \text{ow}) = \frac{18}{60} = 0.3 \]
(e) Overweight given tall: keep the tall column
Why: 50 people.
\[ P(\text{ow} \mid \text{tall}) = \frac{18}{50} = 0.36 \]
(f) Tall AND underweight: a cell over everyone
Why: the crossing cell is 12.
\[ P(\text{tall}\text{ AND }\text{uw}) = \frac{12}{205} = 0.059 \]
Figure (svg): A mosaic of the 205 individuals: columns for overweight (60), typical weight (99) and underweight (46), each shaded from the bottom to the share who are tall: 0.300, 0.202 and 0.261. A dashed yellow line marks 0.244, the share of all 205 who are tall.
(g) Test independence
Why: compare the conditional from part (d) with the marginal from part (b).
\[ 0.3 \ne 0.244 \]
So overweight and tall are not independent in this group: 30 percent of the overweight people are tall, against about 24 percent of everyone. Parts (c), (d) and (e) share the numerator 18 and differ only in the denominator.
Parts (d) and (e) are the two directions of the same cell. Thirty percent of the overweight are tall, but 36 percent of the tall are overweight. Neither number is the other one turned round, which is why the wording of a conditional must be read so carefully.
Check with the product form
Why: the joint from part (c) against the product of the two marginals; they disagree, confirming dependence.
\[ \frac{18}{205} = 0.088 \ne 0.071 = \frac{60}{205}\cdot\frac{50}{205} \]
OpenStax Introductory Statistics 2e, §3.4 Contingency Tables §3.4, pp. 188-189 — Try It 3.23(b) to (g)
Real world
A newspaper reports that 60 percent of the patients who died last year had been treated in the hospital's new intensive care unit, and asks whether the unit is dangerous. The numbers below are hypothetical, built to show the trap.
| died | survived | total | |
|---|---|---|---|
| new unit | 60 | 1440 | 1500 |
| old ward | 40 | 460 | 500 |
| total | 100 | 1900 | 2000 |
Figure (svg): Two panels built from one hypothetical table of 2000 patients. Left: of the 100 deaths, 60 were at the new unit and 40 at the old ward. Right: the death rate is 60 out of 1500, or 0.04, at the new unit and 40 out of 500, or 0.08, at the old ward.
Discussion prompt
Which conditional probability is the newspaper reporting, and which one answers the question of how dangerous the unit is? Compute both.
Whenever a statistic reads X percent of those who had the outcome did the thing, turn it around before you believe it. The claim that matters is almost always the other conditional, and a two-way table is the quickest way to find it.
Real hospitals add another twist: a new intensive care unit usually receives the sickest patients, so even an honest death rate comparison is not a fair test of the unit. The table tells you which question a number answers; it cannot tell you why the numbers came out that way.
Section
Part 6
Pattern
Figure (svg): A flow diagram. Start: check both margins add to the grand total. Then read the wording: a 'given', 'of the' or 'among' sends you to divide a cell by its own row or column total; an AND sends you to a cell over the grand total; an OR sends you to row plus column minus the shared cell, over the grand total; a single description sends you to a margin over the grand total.
The diagram reads left to right. The margin check comes before any division because every answer divides by a total. Then the wording sends you down one of four branches, and each branch names its numerator and its denominator.
The single idea underneath all five steps is that a probability is a share, and a share is always a share of some group. The table makes the group visible; the steps just make sure you name it before you divide.
Use the diagram as a script when you work a new table: point at the margin check, then read the question aloud and follow one arrow. Every example in this lesson went down one of those four branches.
When a question mixes two ideas, such as an OR inside a given, do the given first: shrink the table to the kept row or column, then answer the rest of the question inside it, as in Muddy's door one OR door two given caught.
Ranking
Put these steps for testing independence from a table in a sensible order. Several orders of computation are possible, but only one gives a complete, trustworthy argument.
Put in order
Order the steps of a complete independence check from a contingency table.
Why: Checking the table comes first because a copying error spoils everything after it. The conditional and the marginal can be computed in either order, but the comparison needs both. The last step turns a yes or no into a sentence about the people in the table, with the numbers that justify it.
The final step is the one most often left out. Not independent is only half an answer; a tutor or examiner wants to hear which group is more likely to do what, and by how much.
Compare the two conclusions: the events are not independent, against older cyclists prefer the hilly path 58 percent of the time, compared with 45 percent of all cyclists. The second one names its evidence, and could be checked by anyone holding the table.
Check
This one tests the lesson's central skill. Use the hiking table: 45 women and 55 men; 34 coast, 41 lakes, 25 peaks; 14 men prefer peaks. Before you look at the choices, say the group aloud and write its total.
Check your understanding
What is the probability that a hiker is a man, given that the hiker prefers mountain peaks?
Answer: A
Why: Given peaks keeps only the 25 hikers who prefer mountain peaks. Of those, 14 are men, so the chance is 14 out of 25, which is 0.56. The denominator is the total for the condition after the word given.
If you chose wrongly, redo it by saying the group aloud first: among the hikers who prefer peaks. The number of people in that group is the only possible denominator.
Each wrong choice is one of the other shapes from Part 2: the reverse conditional, the joint, and a marginal. So a wrong pick tells you exactly which habit to repair.
Check
Now an OR, from the speeding table: 305 phone users, 70 drivers with a violation, 25 who are both, 755 in all. Picture the L-shape first: the phone row and the violation column, meeting in one cell.
Check your understanding
What is the probability that a driver uses a phone OR had a violation?
Answer: A
Why: Row plus column minus the crossing cell: 305 plus 70 minus 25 is 350, out of 755. The 25 drivers who are both were counted in the row and again in the column, so they are taken away once. Check by the complement: only the 405 non-users with a clean record are outside, and 755 minus 405 is 350.
A quick bound for any OR: it must be at least as big as the larger of its two marginals, and at most their sum. Here that is between 305 and 375 drivers, and 350 sits inside.
The complement check is even faster on a two-by-two table. The L-shape of the phone row and the violation column leaves out one cell, the non-users with a clean record, so the OR is everybody minus that cell.
Check
Finally, an independence test, from the cyclist table: 90 older cyclists, 52 of them prefer hills; 90 of all 200 cyclists prefer hills. Decide which two rates must be compared before you read the statements.
Check your understanding
Which statement correctly tests whether being older and preferring hills are independent?
Answer: A
Why: Independence compares the chance of hills among older cyclists with the chance of hills among everyone. They are 0.578 and 0.45, clearly different, so the events are dependent: older cyclists prefer hills more than cyclists in general.
The distractor about the joint being nonzero mixes up the two properties from Section 3.2. Mutually exclusive is about a cell being empty; independent is about the rows splitting in the same proportions.
A complete answer would add the context: older cyclists prefer the hilly path 58 percent of the time, against 45 percent of all cyclists in the sample.
Explain it to yourself
Put the lesson's main idea in your own words before the exit ticket. A good explanation is short and uses the table.
Discussion prompt
Using the speeding table, explain in two or three sentences why 25/755, 25/305 and 25/70 are all correct answers, and what question each one answers.
If your explanation used the word among, or the phrase a share of, you have the idea. If it only described which numbers to divide, add the reason: the denominator is the group the question is about.
A good test of your explanation: could someone use it to decide, for a brand-new table, which total goes on the bottom? If it names the group, it passes.
Exit ticket
A school surveys 400 students: 160 play a sport, 120 have a part-time job, and 30 do both.
Discussion prompt
Build the two-by-two table. Then find the probability that a student has a job given that they play a sport, and decide whether playing a sport and having a job are independent.
Fill the table from the one cell you are given, 30, by subtraction: 160 minus 30, then 120 minus 30, then the last cell from either its row or its column. Check the corner both ways before dividing.
Every part of the lesson is in this problem: completing the table, choosing the given row as the denominator, and comparing a conditional with its marginal. If one part felt uncertain, the matching Part is the one to revisit.
Recap
A contingency table sorts one sample by two variables at once. Every probability in this chapter is one of its numbers divided by another, and the only real decision is the denominator.
| asked for | numerator | denominator |
|---|---|---|
| joint: A AND B | the cell where A and B meet | grand total |
| marginal: A | A's row or column total | grand total |
| A OR B | row + column − shared cell | grand total |
| conditional: A given B | the cell where A and B meet | B's own total |
| independence | compare P(A given B) with P(A) | equal means independent |
\[ \text{expected count} = \frac{\text{row total} \times \text{column total}}{\text{grand total}} \]
Next, Section 3.5 draws the same information as tree and Venn diagrams, which are easier when the problem arrives as a sequence of stages rather than as a table of counts. The Business Statistics text treats contingency tables and trees together in one section, which is worth reading for extra practice.
OpenStax Introductory Business Statistics 2e, §3.4 Contingency Tables and Probability Trees §3.4 — contingency tables and probability trees, with business examples
Want this taught 1-on-1? Alexander tutors Statistics — $55/session, free consultation.