Math
A test and a disease
Ten thousand people, a disease and a test: the test sweeps the population and marks the positives, then everyone moves into a 2×2 table of sick or healthy against positive or negative. Guess what share of the positives is really sick, then see the tray - for a rare disease the false ones outnumber the true ten to one. Bayes' rule with this sheet's numbers, the factor you move lit up, the positives retested, and a task that shows specificity, not sensitivity, is the lever.

What happens
Ten thousand people on a square. A disease has a prevalence: one in a thousand, say. A test has a sensitivity - how often it says yes to a sick person - and a specificity - how often it says no to a healthy one. Both 99 %. The sick are amber from the start; you can see them, the test cannot. The test sweeps the square row by row and lights the positives: amber where it caught a sick person, red where it flagged a healthy one. With ten sick people on the square and ten thousand healthy, 1 % of the healthy is a hundred - so a positive means sick about one time in eleven. That is Bayes' rule, and the square is the rule drawn: PPV = ps / (ps + (1 − p)(1 − q)). Drag across the square and the prevalence sweeps on a log scale; the chart is the worth of a positive against prevalence. Retest the positives and the last answer becomes the new prior - 9 % becomes 91 % becomes 99.9 %. The task: at a prevalence of 0.1 %, make a positive worth a coin flip without touching the prevalence. Sensitivity cannot do it even at 100 %; specificity can, at 99.90 %, because the false positives come from the healthy, and there are a thousand of them for every sick person.
Equations used in the module
Equations square: N = 10 000 people, prevalence p; sick = pN, healthy = (1 − p)N test: sensitivity s = P(positive | sick), specificity q = P(negative | healthy); true positives s·pN, false positives (1 − q)(1 − p)N, missed (1 − s)pN value of a positive (Bayes): PPV = ps / (ps + (1 − p)(1 − q)); rare (p = 0.1 %, s = q = 99 %): 9.0 %; common (p = 10 %): 91.7 %; screening (p = 1 %, s = 80 %, q = 90 %): 7.5 % retest: the positives tested again, prior = the last PPV; rare → 9.0 % → 90.7 % → 99.9 % the sampled square: one draw for the disease and one for the test per person through the shared xorshift (seed 1); rare: 13 sick, 13 true and 95 false positives (12.0 % in this draw, 9.0 % exact); common: 1025 / 1018 / 88; screening: 101 / 80 / 985 the lever: at p = 0.1 %, s = 99 % a coin flip (PPV 50 %) needs 1 − q = ps(1 − 0.5)/(0.5(1 − p)), q = 99.90 %; s = 100 % alone gives 9.1 %


