Bayes' theorem, visualized
Bayes' theorem tells you how to update a belief after seeing evidence. Its most famous lesson is the base-rate fallacy: even a highly accurate medical test can leave you far from certain when the condition is rare, because false positives from the huge healthy majority pile up.
This tool shows the whole population as one square. Its width splits by how common the condition is (the prior); the top band of each column is who tests positive. The posterior — the chance you really have it after a positive test — is just the red area as a share of all the positive area.
Slide the three dials — watch the posterior
Posterior P(has it | tested +)
16.7%
Of the 594 who test positive per 10,000, only 99 truly have it.
If the test is negative
100% clear
P(healthy | tested −) — usually reassuringly high.
Free · runs entirely in your browser · nothing to install
How to use it
- Lower the 'prior' toward a rare condition and watch the posterior collapse even with an accurate test.
- Raise the sensitivity and lower the false-positive rate to see the posterior recover.
- Read the 'per 10,000 people' caption to see the true-positive vs false-positive counts behind the ratio.
What you'll take away
- What prior, likelihood, and posterior mean — and how they combine.
- Why the base rate matters as much as the test's accuracy.
- The reasoning behind spam filters, medical screening, and Naive Bayes classifiers.
Want to actually build this?
This demo is one moment inside a full Math to Machine lesson — predict, build, and explain the concept, with an AI tutor that gives hints, not answers. The first five lessons are free.
FAQ
- What is Bayes' theorem in simple terms?
- It's a rule for updating a probability when new evidence arrives: your updated belief (the posterior) is proportional to how well the evidence fits each explanation (the likelihood) times how likely that explanation was to begin with (the prior).
- Why can a 99% accurate test still be wrong most of the time?
- If the condition is rare, the many healthy people who test falsely positive can outnumber the few true positives. The posterior depends on the base rate, not just the test's accuracy — exactly what this tool lets you see.