Bayes’ Theorem Explained: Count Your Way to the Right Answer
The formula for updating a probability is three symbols wide and still manages to defeat most people who meet it — including, in published studies, most physicians. Translated into counts of an imagined 1,000 people, the same calculation becomes something you can verify on your fingers. Here is Bayes’ theorem as natural frequencies, what a second test is genuinely worth, and how the prior quietly decides what your evidence means.
The question Bayes’ theorem answers
Most probability questions run forwards: if 2% of items on a production line are defective, how many will an inspection flag? Bayes’ theorem runs the question backwards: this item was flagged — how likely is it actually defective? The backwards question is the one you face in practice, because you never observe the underlying truth, only the evidence. A test result, a flagged transaction, a spam score: each is a B from which you want to reason back to an A.
The Bayes’ theorem calculator does that reversal from three numbers — the prior P(A), the chance of the evidence when A is true P(B|A), and the chance of the same evidence when A is false P(B|not A). The calculator page covers the formula itself, the odds form, and the classic fallacies. This guide covers the part that makes the formula feel right rather than merely correct: translating it into counts you can check by hand, chaining updates when evidence arrives twice, and reading what a negative result is worth.
Natural frequencies: the version your brain can check
The formula P(A|B) = P(B|A)×P(A) ÷ P(B) is compact but opaque — surveys of physicians given screening problems in percentage form regularly produce answers off by a factor of ten. The fix, championed by Gerd Gigerenzer in the BMJ paper Simple tools for understanding risks, is to stop thinking in percentages and start counting people.
Take the calculator’s default screening example: a condition with 1% prevalence, a test that catches 80% of true cases and false-alarms on 9.6% of healthy people. Now imagine 1,000 people screened:
- 10 have the condition (1% of 1,000). The test catches 80% of them: 8 true positives.
- 990 do not. The test false-alarms on 9.6% of them: 95 false positives.
So 103 people get a positive result, and only 8 of them actually have the condition: 8 ÷ 103 ≈ 7.8%. That is the whole theorem — the posterior is just the share of positives that are true positives. No formula to memorise, nothing to take on faith, and the surprising answer stops being surprising: the healthy group is 99 times larger, so even a modest false-alarm rate produces a crowd of false positives that swamps the handful of true ones. Run the same numbers through the calculator and you get 7.764% — the counting version rounds the 95.04 expected false positives to whole people, which is why it lands a fraction high.
Worked example: a production line, counted two ways
Screening examples are everywhere, so here is the same machinery on a factory floor. A production line runs a 2% defect rate. An automated inspection station catches 95% of defective items but also false-flags 3% of good ones. An item just got flagged — how likely is it defective?
Enter prior 2%, P(B|A) 95%, P(B|not A) 3% into the Bayes’ theorem calculator:
- P(B) = 0.95×0.02 + 0.03×0.98 = 0.019 + 0.0294 = 0.0484 — 4.84% of items get flagged
- Posterior P(A|B) = 0.019 ÷ 0.0484 = 39.26%
- Likelihood ratio = 0.95 ÷ 0.03 ≈ 31.7
In natural frequencies, per 10,000 items: 200 are defective and the station catches 190 of them; 9,800 are good and it wrongly flags 294. Of the 484 flagged items, 190 are genuinely defective — 190 ÷ 484 = 39.26%. Again the counts make the answer legible: the false-flag rate is only 3%, but it applies to a pile of good items 49 times bigger than the defective pile.
Notice how much stronger this test is than the screening test — a likelihood ratio near 32 against 8.3 — and the posterior is still under half. A flagged item is 20 times more likely to be defective than a random one (39.26% against 2%), which is exactly what an inspection station is for, but anyone treating “flagged” as “defective” would scrap three good items for every two bad ones.
The negative side of the ledger is quieter but just as useful. Of the 9,516 items that pass, only 10 are defective — the calculator reports this as P(A|not B) = 0.105%. A pass takes the defect risk from 2% to one in a thousand, which is the number you need when deciding whether passed items can ship without a second check.
Updating twice: what a second test is worth
Bayes’ theorem is built for repetition: today’s posterior is tomorrow’s prior. Suppose the screening example comes back positive, so the probability moved from 1% to 7.76%. A second, independent test of the same accuracy also comes back positive. Feed 7.76% in as the new prior with the same 80% and 9.6%, and the posterior climbs to 41.2%. A third positive takes it to 85.4%.
The odds form shows the pattern: each independent positive multiplies the odds by the same likelihood ratio. Prior odds of 1:99 times 8.33 gives 0.084 (7.76%); times 8.33 again gives 0.70 (41.2%); again, 5.85 (85.4%). Evidence compounds multiplicatively in odds even though the probability scale makes each step look different — which is why statisticians who work with accumulating evidence live in odds, and why the calculator reports prior and posterior odds alongside the probabilities.
The load-bearing word is independent. Running the same rapid test twice on the same sample is not independent — whatever caused the first false positive (a cross-reacting antibody, a contaminated batch) is still there for the second. Chaining updates with correlated evidence double-counts it and produces confident nonsense. A genuinely different test — a different mechanism, a different lab — is what earns the second multiplication. When in doubt, the honest move is to treat the second result as weaker evidence than its stand-alone likelihood ratio suggests.
What moves the posterior
The prior, more than anything
Hold the screening test fixed (80% detection, 9.6% false alarms) and vary only the prior:
- Prior 0.1% → posterior 0.83%
- Prior 1% → posterior 7.76%
- Prior 5% → posterior 30.49%
- Prior 10% → posterior 48.08%
- Prior 25% → posterior 73.53%
- Prior 50% → posterior 89.29%
Same test, same result, and the meaning of a positive ranges from “almost certainly a false alarm” to “almost certainly real”. This is why the same diagnostic performs so differently as a mass screen (prior = population prevalence, tiny) versus a confirmation for a symptomatic patient (prior already 10–50%). No single “accuracy” number for a test can tell you what a positive means without the base rate attached.
The likelihood ratio
The ratio P(B|A) ÷ P(B|not A) is the test’s entire evidential weight in one number. Improving detection from 80% to 95% barely moves it if the false-alarm rate stays put; halving the false-alarm rate doubles it. That asymmetry is worth internalising: for rare conditions, the false-positive rate — the denominator — is almost always the binding constraint, because it acts on the enormous not-A group.
Which direction the evidence points
Evidence with a likelihood ratio above 1 pushes the probability up; below 1 pushes it down; exactly 1 leaves the prior untouched. A negative result is evidence too — its likelihood ratio is (1−0.80) ÷ (1−0.096) ≈ 0.22 in the screening example, dragging 1% down to 0.223%. People routinely over-read positives and ignore negatives, but the arithmetic treats them symmetrically.
Common mistakes
Reading the test’s accuracy as your answer. “The test is 95% accurate, so a flagged item is 95% likely defective” conflates P(B|A) with P(A|B) — the production-line example above shows the true figure is 39%. The two only coincide when the prior is 50%.
Feeding in one “accuracy” number. Bayes’ theorem needs the false-positive rate as its own input. A single headline accuracy figure blends performance on true and false cases in whatever mix the validation study happened to use, and cannot be unpicked into the two numbers the formula requires. Look for sensitivity and specificity separately; the false-positive rate is 1 minus specificity.
Neglecting the base rate under vivid evidence. In Kahneman and Tversky’s taxicab problem, 15% of a city’s cabs are blue and a witness who is 80% reliable says the cab in an accident was blue. Most people answer 80%; the calculator gives 41.4% (exactly 12/29). The witness is genuine evidence — the probability nearly triples — but vivid testimony does not erase the fact that most cabs are green.
Mixing scales. The calculator takes percentages; the formula underneath works in probabilities. Entering 0.8 when you mean 80% silently computes a different problem. If the posterior looks absurd, check all three inputs live on the same scale.
Updating on the evidence you went looking for. If you ran twenty tests and report the one that came back positive, the likelihood ratio of that positive is no longer the stand-alone figure — selection has crept into P(B). This is the same multiple-comparisons trap that inflates significance in hypothesis testing, covered from the frequentist side in the p-value guide.
When the calculation is not enough
The arithmetic is the easy part — the calculator does it exactly. The judgement calls are the inputs. Priors for real decisions are estimates: prevalence varies by age and region, defect rates drift, and a prior of “about 1%” versus “about 3%” changes the posterior by a factor of three. Published sensitivities and specificities come from validation studies whose populations may not resemble yours. For anything that matters — a medical result, a legal question — treat the output as a structured way to think, not a verdict, and take the actual decision with someone who knows the domain and the data source. A clinician interpreting your test result knows things about you that no population prior does.
Frequently asked questions
How do I use the calculator for a second positive test?
Take the posterior from the first calculation and enter it as the prior for the second, keeping P(B|A) and P(B|not A) for the new test. In the screening example, 1% becomes 7.76% after one positive and 41.2% after a second independent positive. This only works when the tests are independent — repeating the identical test on the same sample does not qualify.
What are natural frequencies?
The same information expressed as counts in an imagined population instead of percentages: “of 1,000 people, 10 have the condition; 8 of them test positive, as do 95 of the 990 without it”. The posterior is then just 8 out of 103. Studies summarised by Gigerenzer and Edwards found that both doctors and patients get Bayesian problems right far more often in this format, because the base rate is built into the counts rather than carried as a separate percentage.
How do sensitivity and specificity map to the inputs?
Sensitivity is P(B|A) — the detection rate among true cases. Specificity describes true negatives, so the calculator’s P(B|not A) is 1 minus specificity: a test with 97% specificity has a 3% false-positive rate. The prior is the prevalence in the group actually being tested, which for a symptomatic patient is much higher than the population figure.
Is the posterior the same thing as positive predictive value?
Yes — what epidemiologists call positive predictive value (PPV) is exactly P(A|B), the posterior probability given a positive. Negative predictive value (NPV) is 1 minus the calculator’s P(A|not B). The Bayesian framing makes explicit what the PPV formula hides: predictive values are properties of the test and the population prior together, not of the test alone.
What prior should I use if I do not know it?
Use the best available base rate for the relevant group — a prevalence figure, a historical defect rate, last quarter’s fraud rate — and then test how much it matters: run the calculation with the lowest and highest plausible priors and see whether the decision changes. If it does not, the uncertainty was harmless. If it does, the prior is the thing to research further, and no amount of formula precision substitutes for it. Avoid exactly 0% or 100%, which no evidence can ever move.
Can the posterior be lower than the prior?
Yes — whenever the likelihood ratio is below 1, meaning the evidence is more common when A is false than when it is true. A negative test result is the everyday case: in the screening example a negative takes the probability from 1% down to 0.22%. Evidence is anything that changes the odds, in either direction.
Where is Bayes’ theorem used in real life?
Spam filters score each incoming message by multiplying likelihood ratios for the words it contains — a direct implementation of the odds form. Medical screening programmes set testing thresholds using exactly the prevalence arithmetic above. Courts wrestle with it in DNA evidence, where the match probability is a likelihood, not a posterior. And it underpins Bayesian statistics generally — the alternative to the frequentist machinery of p-values and confidence intervals, in which parameters themselves carry probability distributions that data updates.
Try it yourself
The fastest way to build intuition is to break the numbers and watch what happens: set the false-positive rate to zero and see certainty appear, set the likelihood ratio to 1 and watch the evidence do nothing, drag the prior from 0.1% to 50% and watch the same test change its meaning. The Bayes’ theorem calculator shows every intermediate — P(B), both complementary posteriors, the likelihood ratio and the odds — so each move is visible rather than hidden inside one output. For the forward version of these problems — how many positives to expect in n trials — see the binomial distribution calculator, and for testing whether observed counts fit expected ones, the chi-square calculator. The formula’s standard statements and history are at Wolfram MathWorld and the Stanford Encyclopedia of Philosophy.
Frequently asked questions
How do I use the calculator for a second positive test?
Take the posterior from the first calculation and enter it as the prior for the second, keeping P(B|A) and P(B|not A) for the new test. In the screening example, 1% becomes 7.76% after one positive and 41.2% after a second independent positive. This only works when the tests are independent — repeating the identical test on the same sample does not qualify.
What are natural frequencies?
The same information expressed as counts in an imagined population instead of percentages: "of 1,000 people, 10 have the condition; 8 of them test positive, as do 95 of the 990 without it". The posterior is then just 8 out of 103. Studies summarised by Gigerenzer and Edwards found that both doctors and patients get Bayesian problems right far more often in this format, because the base rate is built into the counts rather than carried as a separate percentage.
How do sensitivity and specificity map to the inputs?
Sensitivity is P(B|A) — the detection rate among true cases. Specificity describes true negatives, so the calculator’s P(B|not A) is 1 minus specificity: a test with 97% specificity has a 3% false-positive rate. The prior is the prevalence in the group actually being tested, which for a symptomatic patient is much higher than the population figure.
Is the posterior the same thing as positive predictive value?
Yes — what epidemiologists call positive predictive value (PPV) is exactly P(A|B), the posterior probability given a positive. Negative predictive value (NPV) is 1 minus the calculator’s P(A|not B). The Bayesian framing makes explicit what the PPV formula hides: predictive values are properties of the test and the population prior together, not of the test alone.
What prior should I use if I do not know it?
Use the best available base rate for the relevant group — a prevalence figure, a historical defect rate, last quarter’s fraud rate — and then test how much it matters: run the calculation with the lowest and highest plausible priors and see whether the decision changes. If it does not, the uncertainty was harmless. If it does, the prior is the thing to research further. Avoid exactly 0% or 100%, which no evidence can ever move.
Can the posterior be lower than the prior?
Yes — whenever the likelihood ratio is below 1, meaning the evidence is more common when A is false than when it is true. A negative test result is the everyday case: in the screening example a negative takes the probability from 1% down to 0.22%. Evidence is anything that changes the odds, in either direction.
Where is Bayes’ theorem used in real life?
Spam filters score each incoming message by multiplying likelihood ratios for the words it contains — a direct implementation of the odds form. Medical screening programmes set testing thresholds using prevalence arithmetic. Courts wrestle with it in DNA evidence, where the match probability is a likelihood, not a posterior. And it underpins Bayesian statistics generally, in which parameters themselves carry probability distributions that data updates.
Informational only. Not personalised financial, legal, or tax advice.