1Conditional Probability¶
1.1The Intuition: Shrinking the Sample Space¶
Let’s start with a concrete situation before we write any formulas.
A local coffee shop tracked 500 customers over a week and recorded two things: whether the customer ordered a pastry, and whether the customer visited in the morning (before noon) or afternoon.
| Morning | Afternoon | Total | |
|---|---|---|---|
| Ordered a pastry | 140 | 60 | 200 |
| No pastry | 160 | 140 | 300 |
| Total | 300 | 200 | 500 |
Suppose we pick a customer at random. What is the probability they ordered a pastry?
Now here’s the twist. Someone tells you: “The customer visited in the morning.” Does this change the probability they ordered a pastry?
Yes, it does. If we know the customer visited in the morning, we’re no longer looking at all 500 customers. We’ve shrunk the sample space to the 300 morning customers. Among those 300, how many ordered a pastry? It’s 140. So:
That vertical bar “” is read “given.” The expression means: “the probability of a pastry order, given that we know the customer came in the morning.”
Notice what happened. The overall probability of ordering a pastry is 0.40. But among morning customers, it jumps to about 0.467. Knowing the time of visit changed our assessment. That’s what conditioning does — it updates your probability by restricting your attention to a subset of outcomes.
1.2The Formal Definition¶
Let’s translate the intuition into mathematics. Look again at what we computed:
Divide both the numerator and denominator by 500 (the total number of customers):
This is the general pattern.
Three things to notice immediately:
The denominator is , not . Conditioning on means becomes our new universe. Everything gets rescaled so that .
must be positive. If , the definition doesn’t apply — you can’t condition on an event that never happens. (Division by zero is undefined.)
is itself a legitimate probability. It satisfies all three axioms of probability. This means every rule you learned in Chapter 2 — complements, unions, inclusion-exclusion — works inside a conditional universe too. We’ll prove this next.
1.3Conditional Probability Satisfies the Axioms¶
1.4Worked Examples¶
EXAMPLE 3.1: Quality Control at a Bottling Plant
A bottling plant inspects bottles for two types of defects: underfilling (less than the labeled volume) and mislabeling (wrong label applied). Records show:
A bottle is pulled off the line and found to be mislabeled. What is the probability that it is also underfilled?
Solution.
Step 1: Identify what we need. We want .
Step 2: Apply the definition.
Step 3: Interpret. Among mislabeled bottles, 40% are also underfilled. Compare this to the overall underfill rate of 8%. Knowing a bottle is mislabeled dramatically increases the chance it’s underfilled — perhaps both defects share a common cause (a malfunctioning machine).
EXAMPLE 3.2: The Asymmetry That Destroys Courtroom Arguments
An auto insurance company classifies 1,000 policyholders:
| Filed a Claim | No Claim | Total | |
|---|---|---|---|
| Under 25 | 75 | 125 | 200 |
| 25 and over | 150 | 650 | 800 |
| Total | 225 | 775 | 1000 |
Compute both and .
Solution.
These are not the same. The first says: “Among drivers under 25, 37.5% file a claim.” The second says: “Among all claimants, 33.3% are under 25.” Different questions, different denominators, different answers.
This is the exact confusion that destroyed Sally Clark’s life. is not the same as . Getting these backwards has a name: the Prosecutor’s Fallacy (also called the fallacy of the transposed conditional or confusion of the inverse). We’ll resolve it formally in Section 3.5 with Bayes’ Rule.
EXAMPLE 3.3: Drawing Without Replacement
A box contains 8 red balls and 4 blue balls. Two balls are drawn one at a time without replacement. What is the probability that the second ball is red, given that the first ball was blue?
Solution.
Let = “second ball is red” and = “first ball is blue.”
After drawing a blue ball first, the box contains 8 red and 3 blue balls — a total of 11 balls. So:
This is higher than the unconditional probability . Why? Because removing a blue ball on the first draw left a higher proportion of red balls remaining.
We can verify this with the formal definition. With 12 balls total and two draws without replacement, there are ordered outcomes.
IN R: Simulation
# Simulate drawing without replacement
set.seed(42)
n_sim <- 100000
box <- c(rep("red", 8), rep("blue", 4))
first_blue <- 0; second_red_given_first_blue <- 0
for (i in 1:n_sim) {
draw <- sample(box, 2, replace = FALSE)
if (draw[1] == "blue") {
first_blue <- first_blue + 1
if (draw[2] == "red") second_red_given_first_blue <- second_red_given_first_blue + 1
}
}
cat("Simulated P(R2 | B1) =", round(second_red_given_first_blue / first_blue, 4), "\n")
cat("Theoretical P(R2 | B1) = 8/11 =", round(8/11, 4), "\n")EXAMPLE 3.4: The Monty Hall Problem — Solved Formally
In Chapter 1, we introduced the Monty Hall Problem and claimed that switching wins 2/3 of the time. Now we have the tools to prove it.
Setup. Three doors. A car is behind one (chosen uniformly at random); goats behind the other two. You pick Door 1. The host (Monty), who knows where the car is, opens a door revealing a goat — say he opens Door 3. Should you switch to Door 2?
Let = “car is behind door ” and = “Monty opens door 3.” We want — the probability that the car is behind Door 2, given that Monty opened Door 3.
The key probabilities we need:
(car is equally likely behind any door).
(if the car is behind Door 1, Monty can open either Door 2 or Door 3; assume he picks uniformly).
(if the car is behind Door 2, Monty must open Door 3 — it’s the only goat door he can open, since you picked Door 1).
(if the car is behind Door 3, Monty can’t open Door 3 — he’d reveal the car).
Apply the definition of conditional probability:
We need by the Law of Total Probability (Section 3.4 — we’re previewing it here):
Therefore:
Switching wins with probability . Staying wins with probability .
Why does switching work? Because Monty’s action is informative. When the car is behind Door 2, Monty is forced to open Door 3 (probability 1). When the car is behind Door 1, Monty opens Door 3 only half the time. So observing “Monty opened Door 3” is twice as likely under as under . Conditioning on Monty’s choice shifts the probability.
Conditional probability is regular probability with a smaller universe. The formula says: restrict your attention to outcomes where happened, and measure how much of that restricted world also has .
The real-life takeaway: Almost every probability you encounter in practice is conditional on something. The unconditional probability is often the least useful number. The skill is recognizing what you’re conditioning on.
The critical warning: in general. The Prosecutor’s Fallacy is the error of treating these as interchangeable. Bayes’ Rule (Section 3.5) is the antidote.
1.5Section 3.1 Exercises¶
Computation
If , , and , find and .
A campus health clinic surveyed 800 students. Of these, 320 received a flu vaccine and 96 got the flu. Among vaccinated students, 16 got the flu. If a student is selected at random and found to have gotten the flu, what is the probability they were vaccinated?
A deck of 52 playing cards is shuffled and two cards are drawn without replacement. Find the probability that the second card is an ace, given that the first card was not an ace.
In a class of 40 students, 12 are math majors, 10 are CS majors, and 5 are double-majoring in both. A student is selected at random and found to be a math major. What is the probability they are also a CS major?
Events and satisfy , , and . Find , , and .
In the Monty Hall problem, suppose the host is not random when the car is behind your door — instead, Monty always prefers to open Door 3 when he has a choice ( instead of ). Recompute . Does switching still help?
Conceptual
Explain in your own words why and are generally different. Give a real-world example (not from this textbook) where confusing the two would lead to a bad decision.
Can ever be larger than ? Can it ever equal zero even when ? Give examples.
If , what does this tell you about the relationship between and ? (We’ll formalize this in Section 3.2.)
Proof
Prove that if and , then and (if ) .
Prove that for any events , with : .
Prove: if , then . (Hint: write both in terms of and rearrange.) Interpret in words.
2Independence of Events¶
The big idea: Sometimes, knowing that one event occurred tells you nothing about whether another event occurred. The weather in Tokyo today has no effect on whether your coin lands heads. When knowing doesn’t change the probability of , we say and are independent.
Why this matters right now: In 2008, the global financial system nearly collapsed. One major cause: banks priced mortgage-backed securities by assuming individual mortgage defaults were nearly independent. They weren’t — when the housing market turned, defaults happened together across entire regions. The mathematical model (David X. Li’s Gaussian copula) used a single correlation parameter calibrated on benign historical data. When defaults stopped being independent, trillions of dollars in “safe” assets became worthless overnight. Independence is an assumption — and getting it wrong can be catastrophic.
In this section, you will learn:
The formal definition of independence and how to verify it
Why independence is not the same as “mutually exclusive”
How to extend independence to three or more events
When independence is a reasonable assumption and when it isn’t
2.1When Conditioning Changes Nothing¶
Look back at Definition 3.1. If , then learning occurred provides zero information about . The probability of is the same whether happened or not.
What does this imply? If , then:
This is symmetric — if and , then:
So if doesn’t affect , then doesn’t affect either. Independence is a two-way street.
Two events and are independent if
Equivalently (when the conditioning is well-defined):
, or
.
Any one of these three conditions implies the other two.
2.2Checking Independence: Verify, Don’t Assume¶
EXAMPLE 3.5: Weather and Transit — Not Independent
A transportation survey of 1,000 commuters:
| Drove | Public Transit | Total | |
|---|---|---|---|
| Rainy | 120 | 180 | 300 |
| Not rainy | 380 | 320 | 700 |
| Total | 500 | 500 | 1000 |
Let = “rainy day” and = “took public transit.” Are and independent?
Check: But
Since , not independent. People are more likely to take transit when it rains.
EXAMPLE 3.6: Two Dice — Surprisingly Independent
Roll a fair die twice. Let = “first roll is 4” and = “sum of both rolls is 7.”
(Only (4,3) has first die = 4 AND sum = 7.)
Check:
Independent! This might be surprising — the sum involves the first roll. But no matter what the first die shows, exactly one value of the second die makes the sum 7.
2.3Independence vs. Mutually Exclusive: The Great Confusion¶
Mutually exclusive means , so . The events cannot happen together.
Independent means . The events don’t influence each other.
These are nearly opposite. If and are mutually exclusive and both have positive probability, then but . So they are not independent — in fact, they are maximally dependent. If you know happened, you know for certain that did not happen: .
The slogan: Mutually exclusive events are maximally dependent, not independent.
2.4Independence of Three or More Events¶
For two events, one equation () suffices. For three events, things get more demanding.
Events , , and are mutually independent if ALL FOUR of the following hold:
Conditions 1–3 alone are called pairwise independence and are NOT sufficient for mutual independence. You need condition 4 as well.
EXAMPLE 3.7: Pairwise but Not Mutually Independent
Toss a fair coin twice. Define:
= “first toss is heads”
= “second toss is heads”
= “both tosses give the same result” (both H or both T)
Then .
Check pairwise: = {HH}, so . Similarly for and .
But: = {HH}, so .
Pairwise independent but NOT mutually independent. Knowing any one event tells you nothing about any other single event. But knowing two of them determines the third with certainty.
2.5When Independence Fails: Real-World Disasters¶
The most devastating failures of the independence assumption come from common-cause failures — when events that look independent share a hidden trigger.
The Fukushima Daiichi Nuclear Disaster (2011). The plant had 13 emergency diesel generators, designed as a redundant backup system. Under an independence assumption, — effectively impossible. But the 9.0-magnitude Tōhoku earthquake triggered a 13–15 meter tsunami (the design basis was only 5.7 meters), which flooded the generator rooms and destroyed 12 of 13 generators simultaneously. The single shared cause — the tsunami — made the “independent” backup systems fail together. This is called common-cause failure, and it’s why engineers must always ask: “What shared event could knock out all of my redundancy at once?”
The lesson for probability students: The multiplication rule is only valid when and are truly independent. When events share a common cause, the joint probability can be orders of magnitude larger than the product suggests. Always justify the independence assumption — never just assume it.
If and are independent, then so are and , and , and and .
Proof (for and ).
Strategy: Express using the fact that and apply the independence of and .
Step 1. Since and partition , and and are mutually exclusive:
Step 2. Solve for :
Step 3. Now substitute (because and are independent):
Step 4. This is exactly the definition of independence for and .
Why this matters: If “rain” and “traffic jam” are independent, then “no rain” and “traffic jam” are also independent. Independence is preserved under complementation — a useful shortcut.
Two machines, and , operate independently. breaks down with probability 0.04; with probability 0.06.
(a) ? (b) ? (c) ? (d) The factory operates if at most one machine is down. ?
(a)
(b)
(c)
(d)
Independence means “no information transfer.” If and are independent, observing doesn’t change your probability for . The mathematical signature is .
Independence ≠ mutually exclusive. These are nearly opposite concepts.
Independence is an assumption, not a fact. The 2008 financial crisis and the Fukushima disaster both resulted from treating correlated events as independent. Always ask: “What shared cause could make these events fail together?”
2.6Section 3.2 Exercises¶
Computation
If , , and , are independent, find , , and .
A system has three components in series (all must work). Each operates independently with reliability 0.95. What is the probability the system functions?
Events and satisfy , , . Independent? Justify.
A password requires a digit (0–9) then a letter (A–Z), chosen independently and uniformly. ?
A fair die is rolled three independent times. ?
Conceptual
True or False: If and are mutually exclusive with and , then they are independent. Justify.
Can an event be independent of itself? For what values of ?
“I flipped heads 10 times in a row, so tails is due.” Use independence to explain why this is wrong.
Give a real-world example of two events that seem unrelated but are actually dependent due to a shared confounder. (Hint: think about ice cream sales and drowning rates.)
Proof
Prove: if and are independent with and , then and cannot be mutually exclusive.
Prove: any event is independent of . That is, .
Prove: any event is independent of . That is, .
3The Multiplication Rule¶
The big idea: Rearranging the conditional probability definition gives — a formula for “both and ” when you know one probability and the conditional probability of the other. This is the multiplication rule, and it handles any sequential process where each stage depends on the previous one.
Why this matters right now: Genetic counseling relies on this. If both parents carry the cystic fibrosis gene (each with probability 1), the multiplication rule on the Punnett square gives a 1/4 chance their child is affected. But the real question is: what’s the probability a random couple both carry the gene and have an affected child? That chains three multiplication steps together — and the answer drives screening policy for millions of families.
3.1The Rule¶
For any two events and :
If and are independent, this simplifies to .
Proof. This is simply Definition 3.1 rearranged. Start with and multiply both sides by .
Extension to three events:
Read this as a chain: start with , then multiply by the probability of given happened, then multiply by the probability of given both and happened.
General form for events:
Strategy: Apply Theorem 3.3 twice — first to the pair and , then to and .
Now expand using Theorem 3.3 again:
Each factor in the chain “inherits” all the conditions from the previous steps. This is why tree diagrams work — each branch carries the accumulated conditions.
3.2Tree Diagrams: The Multiplication Rule Made Visual¶
EXAMPLE 3.8: Airport Security Screening
An airport checkpoint uses two phases. Phase 1: 85% pass, 15% flagged. Phase 2 (for flagged passengers only): 70% cleared, 30% detained.
About 4.5% of passengers are detained.
EXAMPLE 3.9: Genetics — Cystic Fibrosis Carrier Probability
Cystic fibrosis (CF) is caused by a recessive allele. A carrier has genotype (one normal allele , one CF allele ). If both parents are carriers (), the Punnett square gives:
| (from dad) | (from dad) | |
|---|---|---|
| (from mom) | (unaffected) | (carrier) |
| (from mom) | (carrier) | (affected) |
Each cell has probability 1/4. So , , .
Now the real-world question: In the U.S. population of European descent, approximately 1 in 25 people are CF carriers. If two people from this population have a child, what is the probability the child is affected?
Using the multiplication rule with independent carrier status:
This matches the observed prevalence: approximately 1 in 2,500 live births.
EXAMPLE 3.10: Three Cards Without Replacement
Three cards are drawn from a standard 52-card deck, one at a time, without replacement. ?
About 1 in 77. Notice how each conditional probability adjusts for cards already drawn — this is why the multiplication rule uses conditional probabilities, not unconditional ones.
IN R
# Three hearts in a row
p_all_hearts <- (13/52) * (12/51) * (11/50)
cat("P(all three hearts) =", round(p_all_hearts, 6), "≈ 1 in", round(1/p_all_hearts), "\n")
# Simulation verification
set.seed(123); n_sim <- 100000
deck <- rep(c("heart", "other"), c(13, 39))
count <- sum(replicate(n_sim, all(sample(deck, 3) == "heart")))
cat("Simulated:", count/n_sim, "\n")The multiplication rule converts conditional probabilities into joint probabilities. It answers: “what is the probability that ALL of these things happen?” by chaining conditional probabilities along a sequence.
Key insight: Each multiplication by a number less than 1 makes the result smaller. Long chains of individually small failure rates can produce surprisingly high overall failure rates.
3.3Section 3.3 Exercises¶
A box has 6 green and 4 yellow marbles. Two are drawn without replacement. ?
A student answers three independent questions, each correct with probability 0.8. ? ?
In a best-of-three playoff, Team A wins each game with probability 0.6 (independent). Draw a tree diagram and find .
A manufacturing line has four independent inspection stages, each catching a defective item with probability 0.90. If an item is defective, ?
Two cards from a deck of 52, without replacement. Find , , and .
Both parents are carriers of an autosomal recessive condition (). They have three children. Assuming independent inheritance: (a) ? (b) ? (c) ?
(Proof) Prove the multiplication rule for four events: .
4The Law of Total Probability¶
The big idea: Sometimes is hard to compute directly, but becomes easy if you first split the sample space into pieces and compute within each piece. The Law of Total Probability tells you how to combine the pieces: it’s a weighted average of conditional probabilities, not a simple average.
Why this matters right now: During the COVID-19 pandemic, data from Israel showed that 60% of severely hospitalized patients were fully vaccinated, leading some to claim the vaccine didn’t work. But this ignored the composition of the population: over 90% of older Israelis (who are most vulnerable) were vaccinated. Once you condition on age, the vaccine was 85–92% effective in every age group. The aggregate number was misleading because it ignored the partition — a phenomenon called Simpson’s Paradox. The Law of Total Probability is the tool that prevents this error.
4.1Partitions¶
A collection is a partition of if:
(the pieces cover everything), and
for all (the pieces don’t overlap).
Every sample point belongs to exactly one .
The simplest partition is . But partitions can have any number of pieces.
4.2The Law¶
If is a partition of with for all , then for any event :
Strategy: Break into mutually exclusive pieces — one for each element of the partition — then apply Axiom 3 and the multiplication rule.
Step 1. Since partitions , every outcome in belongs to exactly one . So we can write as the union of its pieces within each :
Step 2. These pieces are mutually exclusive. Why? Because if , then (the partition pieces don’t overlap), so:
Step 3. Since the pieces are mutually exclusive, Axiom 3 lets us add their probabilities:
Step 4. Now apply the multiplication rule (Theorem 3.3) to each term: .
Why this matters: The total probability of is a weighted average of , with weights . The larger a partition piece, the more it contributes. This is why a simple average of conditional probabilities is wrong when the pieces have unequal sizes — and why Simpson’s Paradox occurs.
The Law of Total Probability uses , which means “add up the terms for ”:
This is the same sigma notation you saw in calculus for Riemann sums: . Here, each term plays the role of — a value times a weight. In later chapters, when we move to continuous distributions, this sum will become an integral: . The Law of Total Probability is the discrete version of this integral.
4.3Worked Examples¶
EXAMPLE 3.11: Insurance Claim Rates
An insurance company operates in three regions:
| Region | % of Policies | Claim Rate |
|---|---|---|
| Urban | 50% | 8% |
| Suburban | 35% | 5% |
| Rural | 15% | 3% |
The overall claim rate is 6.2% — not the simple average of 8%, 5%, and 3% (which would be 5.33%). The weighted average is higher because the region with the highest claim rate also has the most policies.
EXAMPLE 3.12: Email Spam Filtering
Of all emails, 40% are spam. A spam filter catches 95% of spam (true positive rate) and incorrectly flags 3% of legitimate emails (false positive rate). ?
About 39.8% of all emails get flagged. We’ll use this in Section 3.5 to answer the reverse question: given an email is flagged, what’s the probability it’s actually spam?
4.4Simpson’s Paradox: When Aggregation Lies¶
EXAMPLE 3.13: The Kidney Stone Paradox (Real Data)
This is a real medical study (Charig et al., BMJ, 1986). Two kidney stone treatments were compared:
| Treatment A (open surgery) | Treatment B (percutaneous) | |
|---|---|---|
| Overall success rate | 78% (273/350) | 83% (289/350) |
Treatment B looks better overall. But now stratify by stone size:
| Stone Size | Treatment A | Treatment B |
|---|---|---|
| Small stones | 93% (81/87) | 87% (234/270) |
| Large stones | 73% (192/263) | 69% (55/80) |
Treatment A wins in BOTH groups — but loses overall!
How is this possible? Doctors assigned the harder cases (large stones) disproportionately to Treatment A. Since large stones have lower success rates regardless of treatment, Treatment A’s aggregate was dragged down by having more difficult cases.
This is Simpson’s Paradox: a trend that appears in aggregated data reverses when the data are stratified by a confounding variable.
The mathematical explanation is the Law of Total Probability with unequal weights:
Treatment A:
Treatment B:
Treatment B has more weight on the easy group (small stones: 270/350 = 77%) while Treatment A has more weight on the hard group (large stones: 263/350 = 75%). The weights — not the conditional success rates — drive the aggregate reversal.
The lesson: Never compare aggregate rates without asking “what are the rates conditional on relevant subgroups?” Simpson’s Paradox is the Law of Total Probability warning you that the weighting scheme matters.
A university admits students through three pathways: Regular (60%), Early Action (25%), Transfer (15%). Acceptance rates: Regular 20%, EA 35%, Transfer 10%.
(a) What is the overall acceptance rate?
(b) Among admitted students, what fraction came through Early Action?
(a) Overall: 22.25%.
(b) About 39.3% of admitted students came through EA — even though EA applicants are only 25% of all applicants.
The Law of Total Probability is a “divide and conquer” strategy: split the sample space into pieces where conditional probabilities are known, then combine with a weighted sum.
Simpson’s Paradox is what happens when you forget the weights. A trend can reverse when data are aggregated across groups with different compositions. The cure: always condition on relevant subgroups before comparing.
Connection forward: The Law of Total Probability gives us the denominator for Bayes’ Rule (next section). These two results are inseparable partners.
4.5Section 3.4 Exercises¶
A factory has two lines. Line A: 60% of output, 4% defect rate. Line B: 40%, 6% defects. ?
A disease affects 2% of a population. A test has 97% sensitivity and 4% false positive rate. ?
30% of commuters drive, 50% use transit, 20% bike. During rain, lateness rates are 15%, 25%, 40% respectively. ?
A student guesses on all exam questions. Multiple choice (60% of exam): 1/4 correct. True/false (40%): 1/2 correct. Overall fraction correct?
Three suppliers: S1 (50%, 1% defective), S2 (30%, 2%), S3 (20%, 5%). Overall defect rate?
(Simpson’s Paradox — Jeter vs. Justice) In 1995–1996, Derek Jeter batted .250 (12/48) in 1995 and .314 (183/582) in 1996. David Justice batted .253 (104/411) in 1995 and .321 (45/140) in 1996. Justice has a higher average in BOTH years. Yet Jeter’s combined average over both years is higher. Verify this numerically. Which player was actually better? Explain the paradox.
A politician claims: “Our schools outperform the national average in every demographic group, so we must outperform overall.” Can this be false? Explain using the Law of Total Probability.
5Bayes’ Rule¶
The big idea: The Law of Total Probability computes from conditional probabilities . Bayes’ Rule goes the other direction: given that has occurred, which was responsible? It “inverts” conditional probability — turning into .
Why this matters right now: You take a medical test. It’s positive. The test is “99% accurate.” You think: “I’m 99% likely to be sick.” You’re almost certainly wrong. And if you’re a doctor who makes this mistake — as studies show the majority do — you may subject a healthy patient to invasive, risky follow-up procedures based on a false alarm. Bayes’ Rule tells you the truth, and the truth depends on something most people forget: how common the disease is in the first place.
5.1A Brief History: The Theorem That Almost Died¶
Thomas Bayes (c. 1701–1761) was a Presbyterian minister in Tunbridge Wells, England. He published just two works in his lifetime — neither on probability. The essay that bears his name, “An Essay towards solving a Problem in the Doctrine of Chances,” was found among his papers after his death by his friend Richard Price, who edited it, added an introduction, and communicated it to the Royal Society. It was published in the Philosophical Transactions in 1764 — three years after Bayes died.
The French mathematician Pierre-Simon Laplace independently rediscovered and generalized the result in 1774, putting it in the form we use today.
For most of the 20th century, the theorem was controversial. The dominant school of statistics (led by R. A. Fisher and Jerzy Neyman) rejected it on philosophical grounds. But Bayesian methods quietly proved their worth: Alan Turing used Bayesian reasoning at Bletchley Park to break the Nazi Enigma code during World War II, and the U.S. Navy used Bayesian search theory to locate a lost hydrogen bomb off the coast of Spain in 1966 and the submarine USS Scorpion in 1968.
Today, Bayes’ Rule is everywhere: spam filters, medical diagnostics, machine learning, autonomous vehicles, weather prediction, and the legal system.
5.2Motivating Example: The Rare Disease Test¶
A disease affects 1 in 1,000 people. A test has 99% sensitivity (true positive rate) and 95% specificity (5% false positive rate). You test positive. ?
Most people — including most physicians (a study by David Eddy found 95 out of 100 got this wrong) — guess “about 99%.” Let’s compute the actual answer.
Let = “has disease,” = “tests positive.”
, .
(sensitivity).
(false positive rate).
First, by the Law of Total Probability:
Now:
The probability you have the disease is about 1.9% — NOT 99%.
5.3Understanding the Surprise: Natural Frequency Reframing¶
The result above shocks most people. The psychologist Gerd Gigerenzer showed that reframing the problem using natural frequencies (counts instead of probabilities) dramatically improves comprehension. Let’s try it:
Imagine 100,000 people from the general population get tested.
100 have the disease (prevalence = 0.001).
Of these 100, 99 test positive (sensitivity = 99%).
99,900 do NOT have the disease.
Of these 99,900, 4,995 test positive (false positive rate = 5%).
Total positive tests: .
Of those 5,094 positives, only 99 actually have the disease: .
The 99 true positives are drowning in a sea of 4,995 false alarms. The “99% accurate” test produces a positive result that’s a false alarm 98% of the time — because the disease is rare.
This is why base rates matter. A test can be excellent at detecting a disease but terrible as a screening tool when the disease is uncommon. This is also why a positive screening test always needs confirmation with a second, more specific test.
5.4The Formal Statement¶
If is a partition of with for all , and , then:
Strategy: Combine the definition of conditional probability (Definition 3.1) with the Law of Total Probability (Theorem 3.4). This proof is just two substitutions — but understanding why each substitution works is the key.
Step 1. Start with the definition of conditional probability applied to :
This says: the probability that caused equals the probability that and both occur, divided by the total probability of . We know both pieces.
Step 2. The numerator: apply the multiplication rule (Theorem 3.3) to :
This converts “A and both happen” into “the probability of given , times the probability of ” — which are quantities we typically know.
Step 3. The denominator: apply the Law of Total Probability (Theorem 3.4) to :
This computes the total probability of across all possible causes — the normalizing constant that ensures our posteriors sum to 1.
Step 4. Substitute Steps 2 and 3 into Step 1:
5.5The Vocabulary of Bayes’ Rule¶
| Term | Symbol | Meaning |
|---|---|---|
| Prior | What you believed about before observing evidence | |
| Likelihood | $P(A | B_j)$ |
| Evidence | Total probability of the evidence (the denominator) | |
| Posterior | $P(B_j | A)$ |
In words: posterior = (likelihood × prior) / evidence.
Bayes’ Rule is a learning machine. You start with a prior belief, observe data, and update.
5.6Worked Examples¶
EXAMPLE 3.14: Resolving the Prosecutor’s Fallacy
Return to Sally Clark. The prosecution presented . But the jury needed .
Bayes’ Rule:
The prosecution compared to but ignored the prior: double infanticide is also extremely rare. The statistician Ray Hill later showed that the likelihood ratio actually favored SIDS by 4.5:1 to 9:1. The “1 in 73 million” number was not only wrong (it assumed independence) but also irrelevant without the Bayesian comparison.
The Prosecutor’s Fallacy is precisely the error of presenting as if it were . Bayes’ Rule is the only correct way to invert the conditional.
EXAMPLE 3.15: Identifying the Source of a Defective Part
Three suppliers:
| Supplier | Market Share | Defect Rate |
|---|---|---|
| Alpha | 50% | 1% |
| Beta | 30% | 3% |
| Gamma | 20% | 5% |
A defective component is found. Which supplier most likely produced it?
Step 1:
Step 2: Bayes’ Rule for each:
Gamma is most likely (41.7%) even though it provides only 20% of parts — because it has the highest defect rate. Bayes’ Rule shifts blame toward the supplier with the worst quality.
Check:
IN R
# Bayes' Rule: Supplier identification
suppliers <- c("Alpha", "Beta", "Gamma")
p_supplier <- c(0.50, 0.30, 0.20)
p_defect_given <- c(0.01, 0.03, 0.05)
p_defect <- sum(p_defect_given * p_supplier)
posterior <- (p_defect_given * p_supplier) / p_defect
for (i in 1:3) cat("P(", suppliers[i], "| defect) =", round(posterior[i], 4), "\n")
cat("Most likely source:", suppliers[which.max(posterior)], "\n")EXAMPLE 3.16: The Spam Filter Revisited
From Example 3.12, . If an email is marked as spam, is it actually spam?
A flagged email has a 95.5% chance of actually being spam. The remaining 4.5% are innocent emails caught in the net.
Historical note: In August 2002, programmer Paul Graham published “A Plan for Spam,” describing a Bayesian spam filter that computed using Bayes’ Rule with word frequencies as likelihoods. His approach — essentially the Law of Total Probability applied token by token — achieved over 99.5% accuracy and became the basis for SpamAssassin, Mozilla Thunderbird’s filter, and most modern spam detection.
5.7Why the Base Rate Matters: A Simulation¶
# Rare disease simulation: see Bayes' Rule in action
set.seed(789)
n <- 100000; prevalence <- 0.001; sensitivity <- 0.99; fpr <- 0.05
has_disease <- rbinom(n, 1, prevalence)
test_positive <- ifelse(has_disease, rbinom(n, 1, sensitivity), rbinom(n, 1, fpr))
cat("People with disease:", sum(has_disease), "\n")
cat("Total positive tests:", sum(test_positive), "\n")
cat(" True positives:", sum(test_positive & has_disease), "\n")
cat(" False positives:", sum(test_positive & !has_disease), "\n")
cat("\nSimulated P(disease|+) =", round(sum(test_positive & has_disease)/sum(test_positive), 4), "\n")
cat("Theoretical P(disease|+) =", round(0.00099/0.05094, 4), "\n")A chip factory uses Process A (70%) and Process B (30%). Chips from A pass testing with probability 0.95; chips from B pass with probability 0.80.
(a) Overall pass rate? (b) A chip passes. ? (c) A chip fails. ?
(a)
(b)
(c)
Bayes’ Rule inverts conditional probability. Given evidence, it tells you the probability of the cause. The formula has three ingredients: a prior, a likelihood, and a normalizing constant from the Law of Total Probability.
The base rate matters enormously. A “99% accurate” test applied to a rare disease mostly produces false alarms. The natural frequency reframing (think in counts, not probabilities) makes this clear: 99 true positives vs. 4,995 false positives.
The Prosecutor’s Fallacy resolved: Confusing with is the single most dangerous probability error. Bayes’ Rule is the antidote — and it requires you to account for the base rate.
5.8Section 3.5 Exercises¶
A disease affects 5% of a population. A test has 90% sensitivity and 8% false positive rate. ?
In a forensic investigation, 0.1% of the population matches a suspect’s DNA profile. The DNA test has a 0.01% false positive rate. A random person tests positive. ?
A retailer sells from brands X (40%), Y (35%), Z (25%). Return rates: 5%, 8%, 12%. A product is returned. ?
A friend picks one of two coins randomly: fair (, chosen with probability 0.6) or biased (, chosen with probability 0.4). The coin lands heads. ?
Repeat the rare disease calculation with prevalence increased to 10%. How does change? Why?
(Sequential Bayes) Using the rare disease from the opening example (prevalence 0.001, sensitivity 0.99, FPR 0.05): a person tests positive, then takes a second independent test with the same characteristics, which is also positive. What is ? (Hint: use the posterior from the first test as the new prior.)
(The Cab Problem — Kahneman & Tversky) A city has 85% green cabs and 15% blue cabs. A witness to an accident says the cab was blue. Testing shows the witness correctly identifies cab color 80% of the time. ?
Prove: posteriors from Bayes’ Rule always sum to 1. That is, .
Prove: if , then . Interpret.
(Natural Frequency Exercise) Reframe Problem 1 using natural frequencies: start with 10,000 people, compute counts of true positives, false positives, true negatives, and false negatives, then derive from the counts. Verify it matches your formula answer.
6The Event-Composition Method¶
The big idea: Instead of listing every sample point, you express the event of interest as a composition of simpler events using , , and complements — then apply the laws of probability. This is how engineers compute the reliability of real systems with multiple components.
Why this matters right now: The Space Shuttle Challenger had two O-ring seals per joint — primary and secondary — designed as redundant protection. Under an independence assumption, — vanishingly small. But at 31°F on launch morning, a phenomenon called “joint rotation” could lift both seals simultaneously. The backup wasn’t truly independent of the primary. The event composition was wrong, and seven people died.
6.1The Strategy¶
Define the experiment and identify the target event.
Identify the component events you can work with.
Express the target as a composition using , , complements.
Apply probability laws (additive, multiplicative, complement) to compute the answer.
The hardest step is (3). Always verify your composition contains the same sample points as the target event.
6.2Worked Examples¶
EXAMPLE 3.17: Parallel and Series System
A fire suppression system: two sprinklers (, ) in parallel (at least one must work) and an alarm () in series (must work). Reliabilities: , , . All independent.
System works .
About 98.5% — better than any individual sprinkler, thanks to the parallel design.
EXAMPLE 3.18: “At Least One” via Complement
Five friends each independently attempt a puzzle with success probabilities 0.3, 0.4, 0.5, 0.6, 0.7.
The complement method turned a five-event union into a simple product. This is the most powerful trick in event composition.
You’ll need this repeatedly in Chapters 4–7. If :
Example: The probability that the first success in repeated independent trials occurs on trial is (we’ll call this the Geometric distribution in Chapter 4). The total probability sums to 1:
Also recall: . This will be essential for the Poisson distribution (Chapter 4).
The event-composition method is a strategy: express complex events as compositions of simpler ones, then apply the tools from this chapter.
Two power moves: (1) “At least one” = . (2) Parallel systems use ; series systems use .
The Challenger lesson: Redundancy only works when failures are truly independent. Common-cause failures defeat redundancy.
6.3Section 3.6 Exercises¶
Three independent relays in series, each with reliability 0.98. ?
Two independent servers in parallel: uptimes 0.97 and 0.93. ?
A student applies to four grad programs independently with acceptance probabilities 0.20, 0.30, 0.15, 0.40. ?
A circuit: Path 1 has two switches in series (each 0.9). Path 2 is a single switch (0.8). Paths in parallel. ?
Ten independent smoke detectors, each with . ?
(Proof) Prove: for independent events each with probability , . Then show that as with , this probability approaches 1.
7Random Variables: A First Look¶
The big idea: Everything in Chapters 2–3 is about events. But in practice, we care about numbers: How many defective items? How long until the next bus? What’s the stock price? A random variable is a function that assigns a number to each outcome — the bridge from events to the quantitative probability of Chapters 4–7.
7.1From Events to Numbers¶
Flip a coin three times. The sample space is .
Now define = number of heads. is a function from to :
| Outcome | Outcome | |||
|---|---|---|---|---|
| HHH | 3 | THH | 2 | |
| HHT | 2 | THT | 1 | |
| HTH | 2 | TTH | 1 | |
| HTT | 1 | TTT | 0 |
We can now ask: (three outcomes give exactly 2 heads).
A random variable is a numerical function defined on a sample space. It assigns a real number to each outcome.
Conventions:
Random variables: UPPERCASE (, , )
Observed values: lowercase (, , )
“” means “the probability that the random variable takes the value 2”
A random variable is a function — a rule that maps outcomes to numbers. A specific value like is a realization — the number you get for a particular outcome. Saying “ is a Binomial” means follows a Binomial distribution (a probability rule). It does NOT mean equals a particular number.
Think of it this way: is the recipe; is the meal. The same recipe can produce different meals on different occasions.
IN R
# Random variable: number of heads in 3 flips
set.seed(321); n_sim <- 100000
x <- rbinom(n_sim, size = 3, prob = 0.5)
cat("Simulated distribution of X:\n"); print(round(table(x)/n_sim, 4))
cat("\nTheoretical: P(X=0)=1/8, P(X=1)=3/8, P(X=2)=3/8, P(X=3)=1/8\n")A random variable converts qualitative outcomes into quantitative values. This lets us use calculus, expectation, and variance. Starting in Chapter 4, we shift from “what is the probability of this event?” to “what is the probability that this number takes a specific value?” Everything from Chapter 3 — conditional probability, independence, Bayes’ Rule — carries forward directly.
Confusing with . The most dangerous error in probability. Always identify what’s given (after the bar) and what you’re computing (before the bar).
Confusing independence with mutually exclusive. Mutually exclusive = cannot happen together (). Independent = don’t influence each other (). If both have positive probability, they cannot be both.
Averaging conditional probabilities without weighting. is a weighted average of , not a simple average. This error produces Simpson’s Paradox.
Multiplying without checking independence. only when independent. For dependent events, use .
Ignoring the base rate. A “99% accurate” test applied to a rare disease mostly produces false alarms. Always use Bayes’ Rule with the prior probability.
Assuming independence without justification. The 2008 financial crisis and the Fukushima disaster both resulted from this error. Always ask: what shared cause could make these events fail together?
8Chapter Summary¶
Conditional probability measures in the restricted universe where occurred.
in general. Confusing these is the Prosecutor’s Fallacy.
Independence means . Equivalent: .
Independence ≠ mutually exclusive. These are nearly opposite when both events have positive probability.
The multiplication rule: . Extends to chains. Visualized via tree diagrams.
The Law of Total Probability: — a weighted average over a partition. Simpson’s Paradox is what happens when you forget the weights.
Bayes’ Rule: . Updates prior beliefs with evidence. Base rates matter enormously.
Event-composition method: Express complex events using , , complements. The complement method () is especially powerful.
A random variable is a numerical function on the sample space — the bridge to Chapters 4–7.
You’ve learned the most misunderstood concept in probability: the difference between and . You’ve seen how confusing them sent an innocent woman to prison.
Here’s the uncomfortable question: how many of your own daily judgments confuse cause and evidence?
When you see a successful person and assume they must be talented, you’re estimating . But what you’ve actually observed is — a very different number, because luck, timing, and privilege all play enormous roles.
When a news headline says “people who eat chocolate live longer,” your brain reads causation. But the data only says . Maybe wealthier people eat more chocolate and have better healthcare. The conditional probability is real; the causal story might not be.
Bayes’ Rule isn’t just a formula. It’s a discipline: “What am I conditioning on? What am I computing? What’s my prior?” Develop this habit, and you will reason more clearly than almost anyone around you.
9Chapter Refresh Exercises¶
, , . Find , , . Are and independent?
A factory uses Material 1 (70%) and Material 2 (30%). Pass rates: 92% and 85%. (a) Overall pass rate? (b) A product fails. ?
Three independent sensors detect a leak with probability 0.85 each. (a) ? (b) ? (c) Alarm triggers when ≥2 detect. ?
1% of a population uses an illegal substance. A urine test: 98% true positive, 3% false positive. (a) ? (b) ? (c) Is one positive test enough to convict? Discuss.
Two cards from a 52-card deck, without replacement. (a) ? (b) ? (c) ?
, , , , , , . (a) , independent? (b) , independent? (c) All three mutually independent?
Medical lab: Hospital 1 sends 60% of samples (8% positive). Hospital 2 sends 40% (12% positive). (a) Overall positive rate? (b) A positive sample — ? (c) Two independent samples — ?
(Monty Hall Variant) In the Monty Hall problem, suppose Monty doesn’t know where the car is and opens a door at random. If he happens to reveal a goat (Door 3), should you switch? Compute under this “Ignorant Monty” variant.
(Proof) If , , are mutually independent, prove is independent of .
(Genetics) A woman’s mother was a known carrier of hemophilia A (X-linked recessive). The woman has probability 1/2 of being a carrier. She has three healthy sons. Using sequential Bayesian updating (, ), compute . (Answer: .)
Building with two independent fire exits. Exit 1 blocked with probability 0.1; Exit 2 blocked with probability 0.15. (a) (at least one clear)? (b) Exit 1 is found blocked. Now ?
(Simpson’s Paradox) A hospital reports that Treatment A has a higher survival rate than Treatment B among both young patients and elderly patients. But overall, Treatment B has a higher survival rate. Explain how this is possible. Construct a numerical example.