STAT 101
M3 · Lab
Hands-on lab
A positive test, a rare disease

Open the Probability Simulator's diagnostic-test panel and read the posterior off a highly accurate test for a rare disease, and predict — before you read them off the screen — the probability you are actually sick given a positive result P(D|+), the total probability of a positive P(+), how many of a population test positive, and how that same posterior changes when the disease is common.

Bayes' theorem for a diagnostic test
P(D \mid +) = \frac{P({+}\mid D)\,P(D)}{P({+}\mid D)\,P(D) + P({+}\mid \lnot D)\,P(\lnot D)} = \frac{\text{sens}\cdot\text{prev}}{\text{sens}\cdot\text{prev} + (1-\text{spec})(1-\text{prev})}

A test that is 99% sensitive and 99% specific sounds nearly perfect. But when only 1% of people have the disease, a positive result means the disease is present barely half the time — because the 99% of healthy people produce so many false positives that they match the true positives one-for-one. This is the base-rate effect: the answer depends on how common the disease is (prev), not on the test alone. Bayes' theorem makes it exact, and the confusion counts make it concrete — P(D|+) is not the same as the test's accuracy.

1 / 10
STAT 101
M3 · Lab
Set it up
One panel

Open the Probability Simulator and use the diagnostic-test panel (the one with prevalence, sensitivity and specificity sliders and a confusion table). Each step names the one thing to set; leave the rest.

Set these values
Test panel -> prev = 1%, sens = 99%, spec = 99% Population N = 100000 Read off -> P(D|+), P(+), TP, FP, count-based posterior TP/(TP+FP)

Watch the test readout for the exact posterior P(disease | +) and the total probability P(+), and the confusion table for the true-positive and false-positive counts and the posterior they imply. Every number you predict is printed there.

2 / 10
STAT 101
M3 · Lab
Step 1 of 6
The base-rate surprise

Set prev = 1%, sens = 99%, spec = 99%. Predict the posterior P(D|+) — the chance you truly have the disease given a positive test — then read the test readout.

Expected

The readout shows P(D|+) = 0.5 — exactly a coin flip, despite a test that is right 99% of the time. That is the base-rate surprise.

3 / 10
STAT 101
M3 · Lab
Step 2 of 6
How often the test even fires

Keep the same settings. Predict the total probability of a positive result P(+) — across the whole population, sick or healthy — then read it off.

Expected

The readout shows P(+) = 0.0198 — about 1.98% test positive. Half of those come from the healthy 99%, which is why a positive is only half convincing.

4 / 10
STAT 101
M3 · Lab
Step 3 of 6
Count them: the true positives

Set the population to N = 100000 and read the confusion table. Predict how many people are true positives — sick and flagged — then read the TP cell.

Expected

The table shows TP = 990 true positives — of the 1000 sick people in 100000, the 99% sensitivity catches 990.

5 / 10
STAT 101
M3 · Lab
Step 4 of 6
And the false positives

Same settings, same population. Now predict how many people are false positives — healthy but flagged — then read the FP cell.

Expected

The table shows FP = 990 false positives — the same count as the true positives. Of the 99000 healthy people, 1% are wrongly flagged, and that equals the 990 real cases.

6 / 10
STAT 101
M3 · Lab
Step 5 of 6
The counts agree with Bayes

Read the count-based posterior the table reports: TP/(TP+FP). Predict it from the two counts you just read — 990 and 990 — then read it off.

Expected

The count-based posterior is 990/1980 = 0.5 — identical to the exact Bayes value from step 1. The paradox is real arithmetic, not a rounding artefact.

7 / 10
STAT 101
M3 · Lab
Step 6 of 6
When the disease is common

Now raise prev = 50% and set sens = 90%, spec = 80%. Predict the posterior P(D|+) — with a common disease, is a positive more trustworthy?

Expected

The readout jumps to P(D|+) = 0.818 — even with a weaker test, a positive is now trustworthy. The base rate, not the test, drove the whole surprise.

8 / 10
STAT 101
M3 · Lab
Your turn
Open the sandbox

Everything above is waiting in the Probability Simulator. Slide the prevalence down and watch the posterior collapse while the test stays 99% accurate; slide it back up and watch a positive become trustworthy again; and read the confusion table to see the true and false positives match one-for-one. The test never changed — the base rate did.

9 / 10
STAT 101
M3 · Lab
Wrap-up
What you did
  • Read the posterior P(D|+) = 0.5 for a 99%-accurate test on a 1% disease — a coin flip
  • Found the total probability of a positive P(+) = 0.0198 at those same settings
  • Counted TP = 990 true positives in a population of 100000
  • Counted FP = 990 false positives — matching the true positives one-for-one
  • Confirmed the count-based posterior 990/1980 = 0.5 agrees with the exact Bayes value
  • Raised the prevalence to 50% and watched P(D|+) climb to 0.818 — proof the base rate, not the test, drove the surprise
10 / 10