Bayes' Theorem Calculator: Prior to Posterior Probability Update

simulator intermediate ~7 min
Loading simulation...
Posterior: P(H|E) ≈ 16.1%

With a 1% base rate, 95% sensitivity, and 95% specificity, a positive test only gives a 16.1% chance of truly having the condition. Out of 1000 people, ~10 have the condition (9.5 test positive), but ~50 healthy people also test positive. Only 9.5 out of 59.5 positive tests are true positives — a powerful illustration of the base rate fallacy.

Formula

P(H|E) = P(E|H) · P(H) / [P(E|H) · P(H) + P(E|¬H) · P(¬H)]
P(E|¬H) = 1 - specificity (false positive rate)
PPV = True Positives / (True Positives + False Positives)

What Is Bayes' Theorem?

Bayes' theorem is the mathematical rule for updating beliefs in the light of new evidence. Formulated by Reverend Thomas Bayes and published posthumously in 1763, it provides a precise formula: the posterior probability of a hypothesis H given evidence E equals the likelihood of observing E if H is true, multiplied by the prior probability of H, divided by the total probability of observing E.

The Base Rate Fallacy

One of the most important cognitive biases revealed by Bayes' theorem is the base rate fallacy — our tendency to ignore how common or rare something is when interpreting evidence. A medical test with 95% accuracy sounds highly reliable, but if the disease affects only 1% of the population, a positive result still has roughly an 84% chance of being a false positive. This counterintuitive result has profound implications for medical screening, criminal justice, and any domain where we test for rare events.

Natural Frequencies

The probability tree and dot display in this simulator use natural frequencies — showing counts out of 1000 rather than abstract percentages. Research by Gerd Gigerenzer demonstrates that people understand Bayesian reasoning far better when information is presented this way. Instead of juggling conditional probabilities, you can simply count: out of 1000 people, about 10 have the disease, roughly 9.5 test positive (true positives), and about 50 healthy people also test positive (false positives). So only 9.5 out of ~60 positive tests are genuine.

Interactive Exploration

Use the sliders to see how the posterior changes with different priors, sensitivities, and specificities. Notice how dramatically the posterior drops when the prior (base rate) is very low — this is the mathematical basis of the base rate fallacy. The bar chart at the bottom shows the magnitude of the Bayesian update: how much a single piece of evidence shifts your beliefs from prior to posterior.

FAQ

What is Bayes' theorem?

Bayes' theorem is a formula for updating the probability of a hypothesis based on new evidence. Published posthumously by Thomas Bayes in 1763, it states: P(H|E) = P(E|H)·P(H) / P(E). It is the mathematical foundation for rational belief updating and is central to statistics, machine learning, and decision theory.

What is the base rate fallacy?

The base rate fallacy is the tendency to ignore the prior probability (base rate) when evaluating evidence. For example, even a 95%-accurate medical test produces mostly false positives when the disease prevalence is 1%, because the 5% false positive rate applied to the large healthy population generates more positives than the 95% detection rate applied to the small sick population.

What are natural frequencies and why do they help?

Natural frequencies express probabilities as counts in a reference group (e.g., '10 out of 1000') rather than percentages. Research by Gerd Gigerenzer shows that people reason about Bayesian problems much more accurately when information is presented as natural frequencies rather than conditional probabilities.

How does sensitivity differ from specificity?

Sensitivity (true positive rate) is the probability of a positive test given the condition is present: P(E|H). Specificity (true negative rate) is the probability of a negative test given the condition is absent: P(¬E|¬H). A good diagnostic test needs both to be high, but their relative importance depends on the base rate and the costs of errors.

Sources

Embed

<iframe src="https://homo-deus.com/lab/cognitive-biases/bayes-theorem/embed" width="100%" height="400" frameborder="0"></iframe>
View source on GitHub