Statistics 🎲 Probability

Bayes' Theorem & Base Rates

How to flip a conditional — and why a rare condition can turn even a strong test into a false-alarm machine.

Intro ProbabilityAP Statistics levelCollege Stats 101
💡
The big idea: Your test came back positive — how worried should you be? The answer depends less on how good the test is and more on how rare the condition is. Bayes' theorem is the rule for flipping 'the test is 90% accurate' into the number you actually care about: the chance you truly have the condition given that you tested positive. When the condition is rare, that chance can be surprisingly low, because a small slip-up rate applied to a huge healthy group creates a flood of false positives.
🎯 By the end, you'll be able to
  • Flip a conditional probability: find P(A|B) from P(B|A) using Bayes' theorem
  • Identify the base rate (prior), the likelihood, and the total probability of the evidence in the formula
  • Explain the base-rate fallacy: why a rare condition makes most positive results false alarms
  • Compute a positive predictive value from a base rate, sensitivity, and specificity using natural frequencies
📎 You should already know
  • Conditional probability
  • Basic probability rules

A positive result flips the question

Imagine a screening test for a rare condition. The lab says the test is 90% accurate, and your result comes back positive. It is tempting to conclude there is a 90% chance you have the condition. That feeling is almost always wrong — and the gap between it and the truth is one of the most useful ideas in probability.

The trap is that 90% accurate describes \(P(\text{positive}\mid\text{have it})\): among people who have the condition, how often the test fires. But what you want to know is the reverse — \(P(\text{have it}\mid\text{positive})\): among people who test positive, how many truly have it. These are not the same number, and Bayes' theorem is the tool for turning one into the other.

🔑 Bayes flips the conditional
A conditional probability has a direction. \(P(A\mid B)\) — the chance of A given B — is generally not equal to \(P(B\mid A)\). A test report gives you \(P(\text{positive}\mid\text{have it})\); the decision you face depends on \(P(\text{have it}\mid\text{positive})\). Bayes' theorem is the exact rule that converts the first into the second, and the conversion hinges on one extra ingredient — the base rate.

Bayes' theorem

Bayes' theorem stitches three quantities together:

  • The base rate \(P(A)\) — often called the prior — how common the condition is before any test.
  • The likelihood \(P(B\mid A)\) — how strongly the evidence B points to A (here, the test's true-positive rate).
  • The overall chance of the evidence \(P(B)\) — how often a positive shows up at all, counting both true and false positives.

Put together, they give the flipped conditional you actually want:

\[ P(A\mid B) = \dfrac{P(B\mid A)\,P(A)}{P(B)} \]
Bayes' theorem: the posterior P(A given B) equals the likelihood times the base rate, divided by the total probability of the evidence.
\[ P(A\mid B) = \dfrac{P(B\mid A)\,P(A)}{\,P(B\mid A)\,P(A) + P(B\mid \lnot A)\,P(\lnot A)\,} \]
The same formula with the denominator opened up. A positive can come from the true cases (left term) or from the healthy group's false positives (right term); the base rates P(A) and P(not A) weight each path.

The base-rate fallacy

Here is the heart of it. Suppose a condition affects just 1 in 100 people, and a test is 90% sensitive (catches 90% of real cases) and 92% specific (correctly clears 92% of healthy people). Those sound like strong numbers. Yet because 99 out of every 100 people are healthy, even a modest 8% false-positive rate on that huge healthy group produces a stack of false alarms — often more than the true positives from the tiny group who really have it.

Jumping straight from positive to I have it — while ignoring how rare the condition is — is the base-rate fallacy. The simulation below makes the pile of false positives impossible to miss. Drag prevalence down toward 1% and watch the red false-positive icons swamp the green true-positive ones, while the readout P(have it | positive) sinks far below the test's accuracy.

🎮 Interactive: base rates and false positives LIVE
Each icon is a person. Green = has it and tests positive (true positive); red = healthy but tests positive (false positive); amber = has it but missed; the rest test negative. Lower the prevalence and the red false alarms take over the positive group, so P(have it | positive) drops — even when sensitivity and specificity stay high.
✨ Why the false alarms win
A rare condition means the healthy group is enormous and the group that truly has it is tiny. So even a small false-positive rate, applied to that enormous healthy group, yields a large false-positive count — while the true positives are capped by the few people who actually have the condition. Accuracy is about rates; what you feel after a positive is about counts. The base rate is what converts between the two.

Count people, not percentages

These problems get dramatically easier if you stop juggling percentages and instead picture a concrete crowd — say 1,000 people — and count heads. This trick is called using natural frequencies, and it turns Bayes' theorem into simple arithmetic you can do without the formula.

📝 Worked example: A condition affects 1% of a population. A test correctly flags 99% of people who have it (sensitivity 99%) and correctly clears 95% of those who don't (specificity 95%). You test positive. How likely is it that you truly have the condition?
  1. Start with 1,000 people. A 1% base rate means about 10 truly have the condition and 990 do not.
  2. True positives: 99% of the 10 who have it test positive — about 10 people.
  3. False positives: the test wrongly flags 5% of the 990 healthy people — about \(0.05 \times 990 \approx\) 50 people.
  4. Everyone who tests positive: \(10 + 50 = 60\) people, but only 10 of them truly have the condition.
  5. Flip the conditional: \(P(\text{have it}\mid\text{positive}) = \dfrac{10}{60} \approx 0.167\).
✓ Only about 17% — roughly 1 in 6 — even though the test is 99% sensitive and 95% specific. The condition's rarity, not the test's quality, is what pulls the answer down.
⚠️ Don't confuse the inverse
Reading a positive as P(positive | have it) when you really want P(have it | positive) is so common it has a name: confusion of the inverse. A positive result does shift the odds upward — you are now more likely to have the condition than a random person — but the base rate still anchors the answer. For a rare condition, a single positive from an imperfect test often leaves the probability well below 50%.

Check your understanding

1. A disease affects 1 in 1,000 people. A test detects 99% of true cases and gives a false positive just 1% of the time. You test positive. Roughly how likely is it that you actually have the disease?
Out of 10,000 people, about 10 have it (≈10 true positives), while 1% of the ~9,990 healthy people gives ≈100 false positives. So P(have it | positive) ≈ 10 / 110 ≈ 9%.
2. Why can a highly accurate test still produce mostly false positives?
That is the base-rate fallacy: a tiny false-positive rate applied to a huge healthy group can produce more false alarms than there are true cases.
3. Treating P(disease | positive) as if it equals P(positive | disease) is known as…
The two conditionals point in opposite directions. Swapping them ignores the base rate — the classic confusion of the inverse.
4. Out of 1,000 people, 20 truly have a condition. A test flags all 20 real cases plus 80 healthy people. If you test positive, what is the chance you have the condition?
Positives = 20 true + 80 false = 100. P(have it | positive) = 20 / 100 = 20%.
✅ Key takeaways
  • P(A|B) is generally not the same as P(B|A); Bayes' theorem is the rule that converts one into the other.
  • Bayes weights the likelihood by the base rate (prior), so rare things stay fairly rare even after a positive test.
  • The base-rate fallacy: ignore how common the condition is and you will badly overestimate P(have it | positive).
  • With a rare condition, a small false-positive rate on a huge healthy group produces more false positives than true positives.
  • Natural frequencies — counts out of 1,000 people — make these problems far easier than juggling percentages.