Conditional Probability

Understand P(A|B), the medical testing problem, intuition traps, the multiplication rule, and the law of total probability.

25 min read
Intermediate

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:

P(AโˆฃB)=P(AโˆฉB)P(B)P(A|B) = \frac{P(A \cap B)}{P(B)}

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.

Die Roll

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.

The Classic Screening Test

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:

Screening 10,000 People
Has Disease
Healthy
Total
Test Positive95 (true +)990 (false +)1,085
Test Negative5 (false -)8,910 (true -)8,915
Total1009,90010,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:

P(AโˆฉB)=P(B)ร—P(AโˆฃB)=P(A)ร—P(BโˆฃA)P(A \cap B) = P(B) \times P(A|B) = P(A) \times P(B|A)
Drawing Cards Without Replacement

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:

P(A)=โˆ‘i=1nP(AโˆฃBi)โ‹…P(Bi)P(A) = \sum_{i=1}^{n} P(A|B_i) \cdot P(B_i)
Factory Quality

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:

  1. Each branch represents a possible outcome
  2. Branch probabilities are conditional on the path taken so far
  3. Multiply along branches to get joint probabilities
  4. 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

๐Ÿง  Knowledge Check
1 / 3

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.

Bayes' Theorem
P(A|B) = P(B|A) ร— P(A) / P(B)
P(Has Disease|Tests Positive) = 0.95 ร— 0.010 / 0.059
P(Has Disease | Tests Positive)
16.1%
Update ratio: 16.1x the prior
Probability Tree (per 1000 cases)
1000 Total
Has Disease: 10
No Has Disease: 990
+: 10
-: 1
+: 50
-: 941

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

A only25%AโˆฉB15%B only35%Neither: 25%AB
P(A โˆช B) = 75%
P(A|B) = 30%
P(B|A) = 37%
P(ยฌA โˆฉ ยฌB) = 25%

๐Ÿ’ก 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.

Total trials: 0
P(A) = 0.0%
P(B) = 0.0%
Independence Test:
P(A โˆฉ B) observed:
0.0%
P(A) ร— P(B) expected:
0.0%
P(A|B):0.0%(should โ‰ˆ P(A) if independent)

๐Ÿ’ก 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!