Conditional Probability
Understand P(A|B), the medical testing problem, intuition traps, the multiplication rule, and the law of total probability.
Updating Beliefs with New Information
Regular probability asks: "How likely is this event?" Conditional probability asks something more powerful: "How likely is this event, given that I already know something else happened?"
This is how rational thinking works. You don't assess situations in a vacuum โ you use context. A cough means something different during flu season than during allergy season. Conditional probability formalizes this.
The Definition
The conditional probability of A given B is:
Read this as: "The probability of A, given that B has occurred."
Intuition: Once we know B happened, B becomes our new "universe." We zoom into the world where B is true, then ask how much of that world contains A.
Roll a fair die. What's the probability it's a 6, given that it's even?
- A = {6}, B = {2, 4, 6}
- A โฉ B = {6}
- P(A|B) = P({6}) / P({2,4,6}) = (1/6) / (3/6) = 1/3
Before knowing it's even: P(6) = 1/6. After knowing it's even: P(6|even) = 1/3. The information doubled the probability!
The Medical Testing Problem
This is the most important application of conditional probability, and it trips up nearly everyone โ including doctors.
A disease affects 1% of the population. A test for it has:
- Sensitivity (true positive rate): 95% โ if you have the disease, the test catches it 95% of the time
- Specificity (true negative rate): 90% โ if you're healthy, the test correctly says "negative" 90% of the time
You test positive. What's the probability you actually have the disease?
Most people guess 90-95%. The real answer is about 8.8%.
Let's work through it with 10,000 people:
Has Disease | Healthy | Total | |
|---|---|---|---|
| Test Positive | 95 (true +) | 990 (false +) | 1,085 |
| Test Negative | 5 (false -) | 8,910 (true -) | 8,915 |
| Total | 100 | 9,900 | 10,000 |
Of 1,085 positive tests, only 95 actually have the disease:
P(Disease | Positive) = 95 / 1,085 โ 8.8%
The false positives from the 9,900 healthy people overwhelm the true positives from the 100 sick people. This happens whenever the disease is rare โ the base rate matters enormously.
This is why screening tests for rare diseases use confirmation tests. A single positive result is just the beginning of diagnosis, not the end. Understanding this could save you from unnecessary panic โ or unnecessary surgery.
Intuition Traps
Conditional probability is a minefield for human intuition:
Trap 1: Confusing P(A|B) with P(B|A)
P(positive test | disease) = 95% โ this is the test's sensitivity. P(disease | positive test) = 8.8% โ this is what actually matters to you.
These are NOT the same! Confusing them is called the prosecutor's fallacy and has led to wrongful convictions.
Trap 2: Ignoring base rates
When a condition is rare, even highly accurate tests produce mostly false positives. The rarer the condition, the worse this problem gets.
Trap 3: Assuming symmetry
P(A|B) โ P(B|A) in general. P(being wet | it rained) is high. P(it rained | being wet) is not necessarily high โ you might have been swimming.
The Multiplication Rule (Revisited)
Rearranging the conditional probability formula gives us the general multiplication rule:
Draw 2 cards from a deck without replacement. What's P(both are Aces)?
- P(1st Ace) = 4/52
- P(2nd Ace | 1st was Ace) = 3/51 (one Ace gone, one card gone)
- P(both Aces) = (4/52) ร (3/51) = 12/2652 โ 0.0045
The second draw depends on the first โ they're dependent events, and conditional probability handles this naturally.
The Law of Total Probability
If you can break the sample space into non-overlapping pieces Bโ, Bโ, ..., Bโ that cover everything, then:
A company has 3 factories producing widgets:
- Factory 1: produces 50% of widgets, 2% defective
- Factory 2: produces 30% of widgets, 3% defective
- Factory 3: produces 20% of widgets, 5% defective
What's the overall defect rate?
P(defective) = P(D|F1)ยทP(F1) + P(D|F2)ยทP(F2) + P(D|F3)ยทP(F3) = 0.02(0.50) + 0.03(0.30) + 0.05(0.20) = 0.010 + 0.009 + 0.010 = 0.029 = 2.9%
The total probability law lets us combine information from different sub-groups into an overall answer.
Probability Trees
Probability trees are a visual tool for working through conditional probability problems:
- Each branch represents a possible outcome
- Branch probabilities are conditional on the path taken so far
- Multiply along branches to get joint probabilities
- Add across branches to get total probabilities
For the medical test example:
- First branch: Disease (0.01) vs Healthy (0.99)
- Second branches: Positive vs Negative (with different rates for each)
- Leaf probabilities = products along the path
Trees make it nearly impossible to make the common mistakes โ they force you to account for all cases systematically.
When in doubt, draw a tree. It's the single most reliable technique for solving conditional probability problems correctly.
Test your knowledge
A disease affects 1 in 1,000 people. A test is 99% accurate. You test positive. Is the probability you have the disease close to 99%?
Interactive Playground
Experiment with these interactive tools to deepen your understanding.
๐ฎ Interactive: Bayes' Theorem Calculator
A disease affects 1% of the population. A test is 95% accurate for positive cases and has 5% false positive rate.
Of those who test positive (59), only 10 actually have the condition.
๐ก Base Rate Neglect: Even with a highly accurate test, a low prior probability dramatically reduces the posterior. This is why false positives dominate when testing for rare events!
โญ Interactive: Venn Diagram Visualizer
๐ก Conditional Probability: P(A|B) zooms into circle B and asks what fraction is also in A. Notice how P(A|B) changes as you adjust the intersection!
๐ Interactive: Independence Tester
Generate data from independent or dependent events and see how the statistics differ.
๐ก Key Insight: For independent events, P(A|B) = P(A). The intersection P(A โฉ B) equals the product P(A) ร P(B). Generate dependent data to see how this breaks!