◈ probability mapProb · Ch 07/16
Probability from the coin flip up · chapter 07

07The Base-Rate Trap

Hand the flip a test that is 99% accurate and a disease that strikes 1 in 1000 people. The result comes back positive. The honest chance you are actually sick is under 10% — not 99%, not anywhere close. And nothing is wrong with the arithmetic. That is exactly the problem. We built the whole machine last chapter, and it now runs in both directions, cause to effect and effect back to cause. Right at the end we caught it doing this, and it should have made you uneasy. It is the same Bayes' theorem, with no new axiom and no new trick. We have simply walked it into its most extreme regime, where the prior is tiny and the answer stops matching anyone's gut. So this chapter is really one idea, felt from every angle. When the thing you are testing for is rare, the vast healthy majority manufactures more false positives than the tiny sick group makes true positives. A test everyone calls very accurate can turn out to be nearly useless. We'll make that crowd of false positives visible as a field of a thousand dots, so the shocking number becomes believable. We'll separate the two knobs everyone wants to mash into one, sensitivity and specificity, and show that neither one can be collapsed into a single "accuracy." And we'll meet the same trap wearing a lab coat in medicine and a hoodie in machine learning, where it's called the accuracy paradox. The maths is Chapter 6's. The stakes are the whole real world.

01The shock, made of people

Let's stand on the exact rung we left off on. Chapter 6 ended with Bayes' theorem in full: P(sick | positive) = P(positive | sick)·P(sick) / P(positive). All the drama hides in one innocent-looking piece, the denominator, which we called the evidence. It counts every way a positive can happen: some positives come from a sick person, and the rest come from a healthy person the test got wrong. Plug in a test that is 99% accurate and a disease that strikes 0.1% of people, and the honest posterior is about 9%. The arithmetic is airtight. The answer is absurd to the gut. So here is the naked truth about that right formula: almost nobody believes it. That disbelief is the gap we are about to cross.

recall — Chapter 6's positive test P(+ | sick) = 0.99 P(sick) = 0.001 P(+ | healthy) = 0.01 P(healthy) = 0.999 P(sick | +) = 0.99 × 0.001 0.99×0.001 + 0.01×0.999 = ≈9% AHA no arithmetic error here — the disbelief is the chapter same formula. unbelievable answer.
each box = one number from Ch. 6
hover or tap a box to recall what it means
≈ 9% — right, but hard to believe
correct arithmetic, wrong-feeling answer — that gap is what this chapter closes.
Fig. 1. Chapter 6's exact numbers, plugged straight into Bayes: a 0.99-sensitive test, a 0.001 base rate, a 0.01 false-alarm rate on the 0.999 who are healthy. Hover or tap any box to recall what it means. The arithmetic lands on ≈9% — airtight, and still the number almost nobody guesses. That gap between correct and believable is exactly what this chapter closes.

Before I show you why that answer is believable, let's make the disbelief honest by committing to a guess. Forget the disease for a moment. Take the lecture's own example: a workplace drug test that is 90% accurate, used on a population where 10% of people really do use. You test one employee, and the result comes back positive. Don't compute anything yet. Just feel out a number. What is the chance this employee is actually a user? Fix that figure in your head, lock it in, and then reveal the truth.

90%-accurate test · 10% of staff use → an employee tests POSITIVE. your guess? 0% 100% you: 85% picture 100 employees just like them: ? chance they actually use
A drug test is 90% accurate. 10% of staff use. One employee tests positive. Guess their real odds, then reveal.
lock in a guess, then reveal it
Fig. 2. Drag to lock in a guess, then hit Reveal. Picture 100 employees just like them: 10 use, and the 90%-accurate test catches 9 of those. But 90 are clean — and at 90% accurate, the test still falsely flags 9 of them too. Same count either side of the line, 9 true, 9 false, so a single positive result can't tell the two groups apart: the real odds are 50%, not 90% — a coin flip, and that's exactly why the committed wrong guess sticks.

The real answer is 50%, a coin flip. If you guessed somewhere near 90% you are in excellent company, and you are badly wrong: a positive on that drug test tells you essentially nothing. The reason is a headcount, not an equation, and this is the move that finally makes it click, so slow down here. Stop thinking in fractions and start counting people. Take a room of 1000 employees. Drag the three dials: how common the disease is, how well the test catches the sick, and how cleanly it clears the healthy. Watch the true positives and false positives light up as actual dots. The posterior is nothing more mysterious than this: of all the dots that lit up, what fraction belong to people who are truly sick?

1000 people · a positive test lights the flagged dots — now just count them of everyone who tests positive, this share is truly sick: 9% 1 / 11 lit-sick ÷ all-lit 1 truly sick, lit green 10 healthy, lit red 989 stay dark (test negative)
1 sick among 11 lit — only 9% real
No equation: 1 green dot sits inside 11 lit dots — read the 9% straight off the crowd.
Fig. 3. Stop reading fractions — count people. Of 1000, a positive test lights ~1 truly sick dot green beside ~10 healthy ones red. The posterior is just lit-sick ÷ all-lit, read off the dots: 1 of 11 ≈ 9%. That's why a scary-sounding positive can still be believable — it isn't an equation, it's literally one glowing dot among eleven. Drag prevalence up and watch the green block finally rival the red.

There it is, and you can literally point at it: one true positive glowing inside a small crowd of false positives. The 9% stops being a paradox and becomes something you can count. It is just 1 out of 11 lit dots. That is the entire chapter in one picture. Everything that follows is us working out why the two crowd sizes come out the way they do, and what it means when they do. But first, notice what just happened to your intuition. The fraction version ambushed you. The count version disarmed the trap completely. That is not an accident, so watch the identical numbers rendered both ways at once.

the bare fraction P(D|+) = s·p / (s·p + f·(1−p)) s = 0.90 sensitivity f = 0.09 false-alarm rate 0.90 × 0.02 = 0.018 0.09 × 0.98 = 0.088 P(D|+) = 0.018 / 0.106 = 16.9% = the headcount per 1000 people · each ● ≈ 10 caught missed false alarm well 10 truly sick → 9 caught, 1 missed 990 well → ≈89 false alarms = 16.9%
both views: P(D|+) ≈ 16.9%
the count already bakes p into its size; the fraction has to multiply it in by hand.
Fig. 4. Same question, two skins. On the left, the raw Bayes fraction: P(D|+) reads "probability of disease, given a positive test," built from s (sensitivity, how often a sick person tests positive) and f (the false-alarm rate, how often a healthy person tests positive anyway) — and the base rate p has to be hand-multiplied into both the top and the bottom, or it silently drops out. On the right, the identical arithmetic wearing natural frequencies: a headcount of 1000 people, where p already decided how many dots even start in the "sick" pile before sensitivity or false alarms touch anything. Drag base rate from rare toward common and watch both panels move in lockstep — same green caught-cases, same orange false-alarms, same closing percentage on both sides of the divider. That's the whole trick of natural frequencies: the count doesn't let you forget the base rate, because the base rate is what built the crowd in the first place.

Here's why the counts win. Reason in natural frequencies and every claim you make is a headcount: "1 in 1000, of whom this many, against 999 of whom that many" — the tiny sick group first, then the enormous healthy crowd. Said that way, the base rate is baked into the counts and comes along for free. Reason in bare conditional probabilities instead, and the base rate becomes a separate factor that you have to remember to include. A separate factor is easy to just... forget, and forgetting it is precisely the bug. The mistake even has a name, and it is an old friend from Chapter 6.

P(A | B) reads: probability of A, given B is true you test positive — are you sick? SICK the cause · 1% of people POSITIVE the effect · your result P(positive | sick) = 99% P(sick | positive) = 17% ✗ base rate P(sick)=1% — dropped ↩ same two arrows as Chapter 6, fig 8
AHA — locked to Ch 6
what does the mind actually answer?
swapped: forward stands as backward
AHA — base-rate neglect is Chapter 6's flip, left un-flipped: the mind answers the forward arrow and calls it the backward one.
Fig. 5. The same two arrows from Chapter 6's diagnostic test — forward P(positive|sick) = 99%, backward P(sick|positive) = 17% — now with a name for the mistake. Click brain's shortcut: the pointer jumps to the forward arrow and the base-rate chip flips to dropped — that's the mind treating the easy question as if it answered the hard one. Click the real flip: the pointer jumps to the backward arrow and the base rate flips to included, because it's baked into the 17%. Base-rate neglect isn't a new bug — it's Chapter 6's flip, left un-flipped.

The whole error is one swapped arrow. You want the backward arrow, P(sick | positive): given a positive result, how likely is the disease? The mind quietly grabs the forward arrow instead, P(positive | sick), because that is the arrow the test advertises. In doing so, it drops the base rate on the floor. It answers the easy question and hopes the answer fits the hard one. Base-rate neglect is just the flip, left un-flipped. So the cure is to be ruthless about which direction you are in. And that starts with being ruthless about the two knobs a test actually has.

02Two knobs, never one

"It's 95% accurate" is a lie of omission, and people describe tests that way constantly. A test does not have one accuracy. It has two separate jobs on two separate populations, and it can be brilliant at one job while it botches the other. Let's name both correctly, once and for all, and settle a slip from earlier. Start with sensitivity, which is P(positive | sick): of the people who are sick, what fraction does the test catch? Specificity is P(negative | healthy): of the people who are healthy, what fraction does the test correctly clear? Build the population out on a grid and watch each definition light up its own column.

split by TRUTH → (columns) split by TEST ↓ (rows) N = 1000 people SICK · n=100 HEALTHY · n=900 TEST + TEST − TP 90 true positive FN 10 false negative FP 90 false positive TN 810 true negative hover sensitivity or specificity below every cell belongs to exactly one column and one row
click a definition to light its column
That's why one "accuracy" can't stand in for both — sensitivity and specificity are computed on disjoint populations.
Fig. 6. 1000 people, split two ways: columns by the truth — sick or healthy — then rows by what the test said. Hover or click sensitivity and the whole sick column lights, top cell (TP) and bottom cell (FN) together — because sensitivity is read straight down that one column. Click specificity and the healthy column lights instead. Same grid, same four cells — TP, FN, FP, TN — just two different columns being asked two different questions.

You just watched the grid light one column at a time, and watching is not the same as building. So here is a cold case with no lights to help you: 1000 people, of whom 80 are truly sick. The test flags 72 of those 80 sick people, and 46 of the 920 healthy ones. Drop each count into its own cell. The step that trips everyone is the very first one: which split is the truth about these people, and which is the test's call?

split by TRUTH → (columns) split by TEST ↓ (rows) N = 1000 · prevalence 8% SICK · n=80 HEALTHY · n=920 TEST + TEST − TP 72 true positive ? FP 46 false positive ? FN 8 false negative ? TN 874 true negative ? 46 874 72 8 place all four to reveal the posterior posterior = TP ÷ (TP + FP) — both are the test's + calls
drag each count into its cell
Tip: match sick/healthy to +/− — that's the whole trick.
The word problem, cold
1000 people, prevalence 8% → 80 sick, 920 healthy
test is 90% sensitive — catches the sick
test is 95% specific — clears the healthy

Four raw counts wait above: 72, 8, 46, 874. No cell is labelled yet — work out which truth and which test result each count belongs to, then place it.

Fig. 7. Cold word problem, no lit-up matrix to recognise: 1000 people, 8% prevalence, a 90%-sensitive / 95%-specific test. Drag the four raw counts — 72, 8, 46, 874 — onto the cell each belongs to (or click a chip, then click its cell); a wrong drop bounces back with a one-line reason, a right one locks green or blue. Flip truth = rows and every chip resets — same four counts, axes swapped, so you re-decide TP's neighbours from scratch. Once all four sit still, the posterior falls straight out of the two cells you placed in the positive row: 72 ÷ (72 + 46) = 61%. You didn't memorise the matrix. You built it.

This grid is the confusion matrix, so read it carefully: every one of its four cells has a name you'll meet for the rest of your life. Down the sick column sit the true positive and the false negative. Down the healthy column sit the false positive and the true negative. Sensitivity lives entirely in the sick column, and specificity lives entirely in the healthy one. The two are computed on disjoint groups of people, which is exactly why one number can never stand in for both. That is not a quibble, so let me show it: here are two tests with the same overall accuracy and wildly different verdicts.

sensitivity Se — catches the SICK 99.0% specificity Sp — clears the HEALTHY 90.0% “accuracy” = 1% × Se + 99% × Sp the green Se-slice is at most 1% of this bar overall accuracy 90.1% you just tested POSITIVE. so — how likely are you actually sick? 9.1% P(sick | positive) ≈ 9 of every 100 it flags are sick Same 90.1% accuracy — opposite truth: Test A · 90.1% acc → 9.1% sick Test B · 90.1% acc → 1.1% sick accuracy averaged the two jobs — and buried the botched one
90.1% acc → a + means 9.1% sick
Base rate is fixed: 1 in 100 people are sick. Now hit the two presets. Both read 90.1% accurate — yet a positive from Test A means 9.1% odds of being sick, and from Test B just 1.1%. Same headline number, an gap in what it’s worth. Accuracy is 99% specificity here, so a test can quietly botch every sick person and the headline barely flinches.
Fig. 8. Two knobs feed one number. Sensitivity (Se) is the share of genuinely sick people the test catches; specificity (Sp) is the share of healthy people it correctly clears — two completely separate jobs on two disjoint crowds. Drag them, or hit the presets. Because only 1 in 100 people are sick, “overall accuracy” is 1% × Se + 99% × Sp — almost entirely specificity (watch the green Se-slice of the accuracy bar stay hair-thin). So Test A (catches 99% of the sick) and Test B (catches just 10%) both report 90.1% accurate — identical headline — yet a positive result is worth 9.1% from A and only 1.1% from B. That’s the base-rate trap: “X% accurate” is a lie of omission, because accuracy blends two disjoint jobs into one average and hides the one the test botches.

Look at what "accuracy" did there. It averaged the two populations together and hid which one the test fails on. Both tests post an identical 90% accuracy. One of them hands you a trustworthy posterior. The other hands you a coin flip. The only difference is how they split their errors across sensitivity and specificity. And when the disease is rare, one of those two knobs matters far, far more than the other. Hold sensitivity pinned high, drag specificity down by a few points, and watch the posterior fall off a cliff.

10,000 tested · 100 truly sick (1%) who tests POSITIVE → truly sick false alarm (healthy) TP 99 · FP 99 of 9,900 healthy aha: each lost point taxes the WHOLE healthy crowd — that's the cliff chance a positive test is real P(sick | tested positive) 100% 50% 0% baseline 50% 50% 99/99 50% now Δ vs 99/99 baseline: 0 pts
about a coin flip — still useful
Fig. 9. 10,000 people take a test for a disease only 100 of them actually have — a rare base rate. The crowd on the left is everyone who tests positive; green dots are the truly sick catches, orange dots are healthy people wrongly flagged. On the right, P(sick | tested positive) — the posterior, the real chance a positive result means disease — starts at a coin-flip 50% when both dials sit at 99%. Drag specificity (the seg buttons or slider) from 99%→95%→90% and the crowd floods orange, the bar collapses toward the floor. Now instead drag sensitivity down by the same amount — the bar barely dips. Same size step, wildly different damage: specificity governs the enormous healthy majority, so every lost point mints hundreds of new false alarms; sensitivity only governs the tiny sick minority, so it has far less crowd to spoil.

You just felt a small slip in specificity gut the posterior, while the same slip in sensitivity barely showed. Now stop watching and decide. You are the engineer. The disease is rare, only 1 in 100 people carry it, and you may add five points to exactly one knob. Which knob buys more trust in a positive result? Commit to an answer before you look. The distance between the two options is the lesson, turned into a choice.

10,000 people · 1% get sick · a 90 / 90 test · today's trust in a "+" ≈ 8.3% put the 5 in → sensitivity ? trust in a "+" put the 5 in → specificity ? trust in a "+" each dot ≈ 15 flagged · truly sick · false alarm commit your 5 points, then reveal the crowd you bought
spend your 5 points — pick a knob
The healthy crowd is huge and the sick are few. Bet the 5 points before you see the result — then reveal which knob you actually bought.
Fig. 10. You are the engineer, and you have exactly five points to spend on a rare disease — 10,000 people, 1% sick, a 90/90 test whose "+" you can trust only ≈8.3% of the time. Commit the points to sensitivity or specificity before you see anything, then press Reveal and count the crowd you bought. Sensitivity barely twitches the trust to 8.8%; specificity halves the red false-alarm dots and nearly doubles the trust to 15.4%. Hit show the road not taken to lay them side by side, and switch to common 10% to watch specificity's runaway edge shrink once the disease stops being rare. Same five points — when the sick are few, you're not fighting to catch them, you're fighting to stop drowning in false alarms, so the point goes on specificity.

Feel the asymmetry. Dropping specificity from 99% to 95% sounds tiny, and it guts the posterior: false alarms among the healthy jump from 1 in 100 to 5 in 100. The same wiggle in sensitivity barely registers. That is not a coincidence. It is structural, and once you see the mechanism you can never un-see it. Here is why.

03Why the base rate wins

Here is the engine of the entire trap, and each side of it fits on one line. The true positives are the sick people the test catches: (prevalence) × (sensitivity), a tiny group multiplied by a great hit-rate. The false positives are the healthy people the test wrongly flags: (1 − prevalence) × (1 − specificity), a huge group multiplied by a small error-rate. The whole drama is a fight between those two products. In 1000 people, a 0.1% disease and a 99% test give about 1 real case against 10 false alarms. Put them on the same scale and watch which one wins as you shrink the base rate.

test fixed: sensitivity 90% · specificity 95% — only prevalence moves TP = 0.010 × 0.90 = 0.0090 TP FP = 0.990 × 0.05 = 0.0495 FP 0% 10% 20% 30% posterior = TP ⁄ (TP + FP) — who's winning 0% 100% 15% posterior same 0–30% scale for both TP and FP, above
FP bar wins → posterior 15%
Shrink prevalence and (1-prevalence) barely moves off 1 — so even a tiny false-positive rate (5%) multiplies into a bar that dwarfs TP. A small % of a HUGE group beats a big % of a tiny one.
Fig. 11. Two bars, one scale: TP = prevalence × sensitivity, FP = (1-prevalence) × (1-specificity), both measured 0–30% of the population. Drag prevalence down toward rare 1% and the FP bar swallows the TP bar whole — sensitivity (90%) is far better than the false-positive rate (5%), but (1-prevalence) stays near 1 no matter how rare the disease is, so a small percentage of a huge group outweighs a large percentage of a tiny one. The knot below marks posterior = TP/(TP+FP) and slides to whichever bar is longer — hit crossover 5.3% to park it exactly at 50-50, the one prevalence where the two forces tie.

Here is the crux, flat and plain: a small percentage of a huge number can dwarf a large percentage of a tiny number. Even a near-perfect test, firing on the vast healthy crowd, throws off enough false positives to bury the handful of real true positives that come from the small sick group. That is what the denominator from Chapter 6 was doing all along. The denominator is the evidence, the total-probability sum, and it fills up with the healthy crowd's contribution. The posterior is whatever is left. So the trap is not about the test being bad. It is about the base rate being small. Which means the trap must dissolve as the base rate grows. Slide the disease from rare to common and watch the paradox evaporate.

fixed test — only prevalence moves → 100% 50% 0% prevalence (how common the disease is) — log scale → 0.1% 10% 50% P(sick | +) 9% prevalence 0.10% the shock evaporating
still probably wrong
the same 99%/99% test from this chapter's opening shock — nothing about the test changed. Only the base rate moved, and that alone drags the posterior from 9% up to 99%.
Fig. 12. The same 99%-sensitive, 99%-specific test throughout — nothing about it changes. Only the prevalence slides, and the posterior climbs the curve with it: 9% at 0.1% prevalence (this chapter's opening shock), already 92% by 10%, and 99% by 50%. That's why it's called a base-rate trap and not a bad-test trap — hold the test fixed, raise the base rate, and the shock evaporates.

Watch the posterior climb as the disease gets commoner. At 0.1% prevalence, a positive means 9%. At 10% prevalence, the same test means 92%. By 50% prevalence it means 99%. Identical test, believable again, because the sick group is no longer outnumbered. So every test has a threshold where a positive result tips from probably wrong to probably right: the prevalence at which the posterior crosses 50%. Go back to the 90%-sensitive, 90%-specific drug test and predict where its crossing sits before you drag to it.

test: 90% sensitive · 90% specific (the drug test) guess 3.0% 100% 50% 0% 0% 10% 20% prevalence — % of the population truly sick 10%
drag to your guess, then hit reveal
Why 10%: true positives = prevalence × 90%. false positives = (1 − prevalence) × 10%. At 10% prevalence, out of 100 people that's 9 true positives vs 9 false ones — dead even. Below 10%, the huge healthy majority's 10% error rate out-produces the tiny sick group's 90% hit rate, so a lone positive is more likely a false alarm.
Fig. 13. The test is fixed — 90% sensitive, 90% specific, the same drug test from earlier. Drag the white pin to where you think a positive first becomes more-likely-true than false, then hit Reveal: a gold band lands at the real answer, 10% prevalence. Below that gold line the blue zone means a positive is coin-flip-or-worse; above it, the green zone means the test can be trusted. The mechanism is arithmetic, not magic — see the aha note.

That crossover point is the honest summary of the whole regime. Below it, a positive result is more likely a false alarm than a real detection. No amount of staring at the test's advertised accuracy will tell you that. Only the flip, run with the real base rate, will. Now let's push both knobs to their breaking point and watch a "perfect" test reveal itself as a fraud.

04The always-positive trap

Here is the cheapest way to build a test that is 100% sensitive, one that has never once missed a sick person: make a test that always says positive. It cannot possibly miss a sick person, because it flags everyone. Its sensitivity is a perfect 100%. Its specificity is a catastrophic 0%, because it flags every healthy person alive too. So when someone brags that their test is 100% sensitive, ask them how. Watch what this one does to the posterior.

sensitivity 95% specificity flags EVERYONE 95% P(sick | positive) 0% 50% 100% 10% prior 68% posterior moved 58 pts of real signal
10%→68% — the test moved you
aha — flip sensitivity to 100% by flagging everyone and specificity is forced to 0%. With sp=0, the false-positive rate equals 100% too, so Bayes reduces to posterior = prevalence exactly. A test that always says yes can't move your belief past the prior it started with.
Fig. 14. Click always positive: sensitivity jumps to a perfect 100% while specificity is forced straight down to 0% — the test now flags every healthy person too, so the false-positive rate hits 100% and swamps the count exactly as much as the true positives do. Watch the posterior marker slide down the belief track until it lands right on top of the gold prior marker: no movement, no information. Drag how common to any prevalence and toggle back and forth — under always positive the posterior equals the prevalence exactly, every time, because a machine that always says yes has nothing left to tell you.

The posterior falls straight back to the base rate. The test told you nothing you didn't already know before you ran it. So you cannot buy safety with a single knob. A test that is all sensitivity and no specificity is just a machine for saying "yes," and a machine that always says yes carries no information at all. Now for the part that should make every ML engineer sit up, because it is the identical maths under a different name, with much bigger stakes. Consider a classifier trained to flag a rare event: fraud, a tumour, one bad transaction in a million.

100% 50% 0% 99.9% ACCURACY looks like a champion 0.0% RECALL frauds it actually caught OUT OF 1,000 CASES are actually fraud 1 the model flags as fraud 0 frauds it caught 0 / 1 it wins by never once saying “fraud” — same trick as a test that always says “healthy”
99.9% accurate, catches 0 frauds
Accuracy just counts the 999 easy “no”s it gets for free — on a rare class it’s the wrong number.
Fig. 15. The always-“not fraud” model never predicts the event, so on a rare class its accuracy towers — 99.9% at a 1-in-1000 base rate — while its recall sits flat on the floor at 0%: it catches none of the frauds it was built to find. Drag the base rate rarer and watch accuracy climb toward 100% for doing nothing. That’s why accuracy is the wrong score on imbalanced data — the identical maths as a test that always says “healthy.”

This is the accuracy paradox, and it is the always-positive test mirror-imaged: the same fraud, run the other way. Say the event you are detecting happens 0.1% of the time. Now build a model that never predicts it, one that answers "healthy," "not fraud," "no" every single time. It is right about the other 99.9% of cases, so it scores a dazzling 99.9% accuracy while catching zero of the cases you actually care about. Its recall is 0%. It is worse than useless, and on a naive accuracy leaderboard it looks like a champion. That is why accuracy is the wrong number to optimize on imbalanced problems, and why the flip tells you the right ones.

10,000 patients · prevalence 1% scan + scan − has cancer no cancer TP hit 90 FN miss 10 FP false alarm 990 TN correct reject 8,910 col 1 = your '+' calls → feeds PPV recall = sensitivity 90% same in all 3 fields precision = PPV 8.3% most '+' calls false ↓ the base-rate trap
PPV 8.3% — most '+' calls are false
same vocabulary, locked
medicineMLformula
sensitivityrecallTP/(TP+FN)
specificitytrue-neg rateTN/(TN+FP)
PPVprecisionTP/(TP+FP)
prevalencebase rateP(+)
recall never moves — it only asks "of the real positives, how many did we catch?" Precision asks the dangerous question, "of our positive calls, how many were real?" — and that one lives or dies by how rare the real thing is. Same warning, three fields.
Fig. 16. The same four cells as Fig. 6, transposed — truth now runs down the rows, the test's call across the columns. Hold the test itself fixed — 90% sensitivity, 90% specificity, in every field — and switch only the rarity of the real thing: a 1% tumour prevalence, a 20% spam rate, a 0.1% fraud rate. Recall (medicine's sensitivity) never budges, because it only looks inside the actually-positive row (TP and FN). Precision (medicine's PPV) looks inside the predicted-positive column instead — and that column fills up with false alarms exactly when the real thing is rare, so it swings from 69% down to under 1%. It's the same division, TP over (TP+FP), wearing a different coat in a hospital, an inbox, and a bank — which is exactly why one warning about a rare class covers all three.

Fig. 16 gave you two words, recall and precision, and let you swing them. But a beginner walks away holding two vocabulary items instead of two ideas, so look at what actually differs between them. Both scores start from the very same corner cell, the true positives. Recall divides that cell by itself plus the sick you missed; precision divides it by itself plus the false alarms you raised. One numerator, two neighbours. Pick the neighbour and you have picked the score.

the shared numerator — always the same TP · true positives 90 TP 90 + FN 10 the sick I missed = 90% RECALL 90 / 100 TP ÷ (TP + one neighbour) out in the world right now: FP = 990 false alarms recall never counts them · precision's denominator is made of them
recall = 90 / 100 = 90%
Same 90 on top either way. Toggle which neighbour joins the bottom: the 10 sick you missed → recall 90%, or the 990 false alarms → precision 8.3%. Now drag prevalence rarer — only the false-alarm denominator balloons, so precision craters while recall sits still.
Fig. 17. One number on top, two different neighbours on the bottom. The true positives (TP = 90) are the shared numerator — they never change. Hit “add the sick I missed” and the 10 false negatives drop into the denominator: recall = 90/100 = 90%. Hit “add my false alarms” and the 990 false positives drop in instead: precision = 90/1080 ≈ 8.3%. Only ever one cell moves — that single choice of neighbour, not any “row versus column,” is the whole difference. Now drag prevalence rarer and watch: only the false-alarm pile balloons (FP 990 → 1990 → 9990), so precision’s denominator swells and its score collapses toward 0.9%, while recall’s denominator of 100 sits perfectly still at 90%. That is exactly why precision depends on the base rate and recall never does.

File that pairing away. In medicine the two knobs are called sensitivity and specificity. In machine learning they are called recall and precision. The warning is identical in both: a single accuracy number, laid over a rare class, is a lie. Same trap, three fields, one flip. So what do you actually do when your test is honest but weak and the disease is rare? You don't throw the test away. You use it correctly.

05Screen, then confirm

Let's pin the exact number the way the lecture does, so nothing here is hand-waved. Take its drug-test figures: 90% sensitive, 90% specific, 10% users. Step through the three lines of the flip. In 100 employees, 9 users test positive and so do 9 non-users, so the answer is 50%. Now make the test worse on the healthy side, dropping specificity to 80%, and run it again. The false positives double to 18 against the same 9 real ones, so the posterior sinks to 1 in 3. Watch the plug-in happen one beat at a time.

100 people · 10 truly +, 90 truly − 10 truly + 90 truly − TP 9 FP 9 TN 81 50% 100 people · 10% base rate → 10 pos / 90 neg sensitivity 90% → TP = 9, FN = 1 specificity 90% → FP = 9, TN = 81 P(true|+) = 9 / (9+9) = 9/18 = 50% specificity drops to 80% → FP = 18, TN = 72 P(true|+) = 9 / (9+18) = 9/27 ≈ 33%
step 1/6
100 people · 10% truly positive
aha: only 3 numbers own the answer — sensitivity, specificity, base rate. Weaken just one, and a "90% accurate" test gets fooled twice as often.
Fig. 18. Step through the exact arithmetic behind the base-rate trap. Out of 100 people, 10 are truly positive; a 90% sensitive test catches 9 of them, but a 90% specific test still misfires on 9 of the 90 healthy people — so 9 real cases sit inside 18 total positives, a flat 50%. Hit next again and change nothing else: specificity alone slips to 80%, false alarms double to 18, and those same 9 real cases are now buried inside 27 positives — just 1-in-3. Three honest numbers gave a coin flip; one worse knob gave you 1-in-3. The test didn't get worse at catching disease — it got worse at leaving healthy people alone, and that's what wrecked the answer.

A 33% posterior from a positive result is genuinely bad. Trust it and you would be wrong two times in three. But the lecture's own instinct is the right one: if you really needed to know, you wouldn't stop there. You would screen everyone with the cheap test, then confirm each positive with a second one. And here is the beautiful part: this is Chapter 6's belief-update loop, back for real work. The first test's posterior is not the end of the story. It becomes the prior for the second test. Run two independent tests in sequence and watch two mediocre results compound into near-certainty.

same disease · two independent 99%-accurate tests, run one after the other prior 1% TEST 1 99% catch · 99% clear ×99 posterior 1 → becomes prior 2 carried forward TEST 2 99% catch · 99% clear ×99 posterior 2 the same number, on a 0–100% ruler 0% 50% 100% two false-positives back to back, by chance: 1% × 1% = 0.01% — about 1 in 10,000
start: base rate 1 in 100
click Run Test 1, then Run Test 2 — watch two so-so tests compound toward certainty.
Fig. 19. The loop from the belief-update chapter, run twice on the same person. Prior starts at the base rate, 1 in 100. Click Run Test 1: a 99%-accurate test carries the prior's odds forward — ×99 — and the posterior lands at exactly 50%, a coin flip, not proof. That posterior becomes Test 2's prior ("carried forward"). Click Run Test 2: the same ×99 update runs again, and the posterior vaults to 99% — read it off the ruler underneath and see how far it jumped in one more step. Why does a second mediocre test do that much work? Because a healthy person would need two independent false-positives to fake it, and at 1% each that's 1% × 1% = 0.01% — about 1 in 10,000. That's the whole trick: no single test is good enough to trust alone, but chaining a second independent one multiplies away the doubt. Screen wide, then confirm narrow.

That ×99 you watched carry the odds forward is not a fluke of these particular numbers. It is the whole flip folded into one multiplier, and it has a name: the likelihood ratio. It is the sensitivity divided by the false-positive rate, so 99% caught among the sick against 1% wrongly flagged among the healthy gives 99% ÷ 1% = 99. Write your belief as odds rather than a probability and Bayes shrinks to one line: prior odds × LR = posterior odds. Better still, it shows why two tests compound. You simply multiply their two ratios. Drive it once by hand and the full fraction never has to come out again on a screening problem.

Bayes, in odds: posterior odds = prior odds × likelihood ratio PRIOR ODDS 1 : 99 prevalence 1% × LIKELIHOOD RATIO ×99 0.99 ÷ 0.01 (Se ÷ 1−Sp) = POSTERIOR ODDS ? the current belief — the SAME number as odds and as probability 0% 50% 100% 1 : 99 odds → 1% chance sick
guess a %, then reveal the ×
Bayes is one multiply in disguise — set the prior and the LR, predict, then reveal.
Fig. 20. Written in odds instead of probability, Bayes collapses to one multiplication: posterior odds = prior odds × likelihood ratio, where LR = Se ÷ (1−Sp). At the default 1% prevalence the prior odds are 1 : 99, and a 99/99 test has an LR of 0.99 ÷ 0.01 = ×99. Set your guess for the posterior, then hit Reveal the ×: the odds just multiply — 1 : 99 × 99 = 1 : 1, exactly 50% (Fig. 19's Test 1). Press Stack a 2nd test and the same ×99 lands again — 1 : 1 → 99 : 1, 99% (Fig. 19's confirm). Load the 99 / 5 test to watch the LR fall to 0.99 ÷ 0.05 ≈ ×20. The meter underneath shows the one belief in both forms at once, so odds is never mistaken for probability. The aha: evidence doesn't set your belief — it multiplies your odds, and a second independent test just multiplies again.

That is the resolution of the whole trap. A single weak test drowns in false positives. But a positive on two independent tests is a far rarer coincidence for a healthy person to produce by luck. The second flip starts from the elevated prior the first test left behind, and it vaults the posterior up toward certainty. Screen wide and cheap. Confirm narrow and hard. Now let's prove the posterior with no formula at all, which is the thing this course can do that no lecture can. Simulate a million people, tag each one sick or healthy by the base rate, run the noisy test on every one, and just count the true and false positives. Predict where the empirical posterior lands, then run it.

the sim — it actually runs: N = 1,000,000 for person in N: sick = rand() < 0.01 if sick: pos = rand() < 0.90 else: pos = rand() < 0.10 if pos: tally(sick) posterior = TP / (TP+FP) » press Run to execute → stdout › people simulated 0 sick & flagged: 0 healthy & flagged: 0 brute force algebra
predict a %, then press Run
No formula yet — predict a %, then let a million people decide.
Fig. 21. No formula this time — a real headcount. The code on the left actually runs: it tags 1,000,000 people sick or healthy at a 1% base rate, tests each one (90% sensitivity, 90% specificity), and only counts who tested positive. Predict the posterior before you press Run — then watch a million individual coin-flips settle on almost exactly what the algebra gives, ≈8.3%. Hit it again and it lands there every time. That's the strongest proof there is: not an equation you're asked to trust, but a crowd you can count.

The empirical fraction of positives who are truly sick lands right on the number the flip predicted. There was no Bayes' theorem anywhere in that loop, just a million coin-tosses and a tally. That is the strongest kind of proof there is: the algebra and the brute-force headcount agreeing to the decimal. The trap is real, the maths is honest, and the picture and the simulation say the same thing.

06You are here

This chapter is the capstone of everything we have built about inference, so let's place it on the family tree. We added no new formula here. The base-rate trap is Chapter 6's flip, run in the rare-event regime: the prior is tiny, and the denominator fills with false positives. Everything upstream fed into it. The measure came from Chapter 3, conditioning from Chapter 5, and total probability and the flip from Chapter 6. All of it converges on the single most consequential mistake people make with probability in the real world. Find our rung, lit gold.

the spine so far 01 02 03 · measure 04 part I — foundations 05 · conditioning 06 total probability the flip 07 · the base-rate trap YOU ARE HERE no new formula — just the flip, run where the prior is tiny.
tap the spine to trace its roots
Hover — or tap — the spine. The dashed threads show exactly what this chapter reuses, and nothing else.
Fig. 22. Hover — or tap — the spine: chapter 07 · the base-rate trap lights up gold, and three dashed threads pull taut back to conditioning (ch 5) and total probability and the flip (both ch 6). Nothing new got bolted on to reach this rung — it's the same machine from Ch 6, reused where the prior is tiny and the false positives pile up. That's why the whole chapter is one idea, felt from every angle.

Now we turn one of the biggest corners in the whole book, so let's cross it deliberately. Look back at everything we have done since Chapter 1. It has all been about events: subsets of the sample space, things that either happen or don't. "The card is a spade." "The test came back positive." Yes or no, in or out. But notice how often we have secretly wanted a number instead: how many people test positive, how many heads in ten flips, how many of the crowd are truly sick. The instant you attach a number to each outcome, the event {k positives} stops being a yes/no subset and becomes the value k. That function from outcomes to numbers is the random variable, and the entire second half of this course is built on it. See the hinge.

Ω — 3 test results, each + or − X = number of positives (a random variable) 0 1 2 3 k = number of positives, out of 3 1 3 3 1
8 outcomes, each its own +/− pattern
aha: {k positives} used to be a subset of Ω — now it's just the number k on a line. That's what Ch.8 calls a random variable.
Fig. 23. Eight tiles, one per possible outcome of 3 test results — each tile is a +/ pattern, a single point in the sample space Ω. Click X numbers (or drag morph) and watch every tile slide onto the number line and shrink into its count k = how many +'s it has. The three tiles with exactly one + don't just "relate to" k=1 — they collapse onto it, and the pile height (1, 3, 3, 1) is the count of outcomes at each k. The event {k positives} stops being a subset of Ω and becomes the value k itself — that assignment, outcome → number, is a random variable, and it's the hinge the next chapter swings on.

That is the pivot. For seven chapters we have measured the chance that something happens. From here on we measure the chance that a number takes a particular value. That single shift unlocks distributions, expectation, variance, and the whole zoo of named laws waiting downstream. The base-rate trap was the last and hardest lesson of the events world. Now we give each outcome a number, and probability becomes something you can add, average, and predict. Turn the page.

iolinked.com
Written by Ajai Raj