Calculateus

Bayes' Theorem Calculator

Calculate the probability of a hypothesis given new evidence, using Bayes' Theorem.

Result

P(A|B) - Posterior Probability
16.102%
P(B) - Total Probability of Evidence
5.9%

About the Bayes' Theorem Calculator

This calculator applies Bayes' Theorem to update the probability of a hypothesis after observing new evidence. It is commonly used to interpret diagnostic test results, spam filters, and any situation where a prior belief needs to be revised in light of imperfect evidence. The default example models a disease test, showing how a low base rate can make even an accurate test misleading.

How It Works

You enter three probabilities as percentages: the prior probability of the hypothesis being true, P(A); the probability of observing the evidence if the hypothesis is true, P(B|A), such as a test's true positive rate; and the probability of observing the evidence if the hypothesis is false, P(B|not A), such as a test's false positive rate. The calculator combines these into the total probability of the evidence, P(B), by weighting each likelihood by its corresponding prior. It then divides the joint probability of the hypothesis and evidence by that total to produce the posterior probability, P(A|B).

P(A|B) = [P(B|A) x P(A)] / P(B), where P(B) = P(B|A) x P(A) + P(B|not A) x (1 - P(A)).

Examples

Low base rate disease test

With the defaults, a 1% prior prevalence, 95% test sensitivity, and a 5% false positive rate, a positive result yields a posterior probability of only about 16.10%, even though the test is 95% accurate in both directions. The total probability of testing positive across the population, P(B), works out to about 5.90%.

Spam filter keyword

If 20% of incoming email is spam, and the word 'free' appears in 60% of spam messages but only 5% of legitimate ones, the probability that an email containing 'free' is actually spam comes out to 75%, computed as (0.6 x 0.2) divided by (0.6 x 0.2 + 0.05 x 0.8).

Advantages

  • Turns an easy-to-misstate concept into a direct number, making the gap between test accuracy and real-world reliability concrete.
  • Requires only three inputs, so it can be used quickly to sanity-check claims about diagnostic tests, filters, or classifiers.
  • Reports the total probability of the evidence, P(B), alongside the posterior, showing how likely a positive result is overall, not just how to interpret one.

Common Mistakes

  • Confusing P(B|A) with P(A|B), a common error known as the prosecutor's fallacy, treating test accuracy as if it were the answer itself.
  • Leaving out or underestimating the prior probability, and assuming a positive result is almost certainly true just because the test is described as highly accurate.
  • Entering P(B|not A) as if it were 1 minus the sensitivity rather than the actual false positive rate, which are only equal by coincidence in specific setups.

Edge Cases to Watch For

  • If both likelihoods work out to make P(B) equal zero, for example if both P(B|A) and P(B|not A) are entered as 0%, the calculator returns an error since the posterior would require dividing by zero.
  • This version handles exactly two hypotheses, A and not A, and a single piece of evidence; it does not chain multiple pieces of evidence together or handle more than two competing hypotheses in one calculation.
  • Extremely small prior probabilities combined with imperfect test accuracy routinely produce a posterior far lower than the test's stated accuracy, which is expected behavior, not a calculation error.

Common Use Cases

  • Healthcare professionals and students interpreting how a test's sensitivity and specificity translate into real diagnostic confidence for a given prevalence.
  • Developers of spam filters, fraud detectors, or anomaly detection systems estimating how reliable a flagged result really is.
  • Anyone updating a belief with new information, such as evaluating how much a single data point should shift an existing assumption.
Written & fact-checked by the Calculateus TeamLast updated August 5, 2026How we verify our formulas

Frequently asked questions

What is Bayes' Theorem?

P(A|B) = P(B|A) × P(A) / P(B) - it updates the probability of a hypothesis (A) after observing new evidence (B), combining your prior belief with how likely that evidence is under different hypotheses.

Why can a 95%-accurate test still be wrong more often than not?

When the prior probability (base rate) of a condition is very low, even a highly accurate test produces many more false positives than true positives in absolute terms - this is the classic 'base rate fallacy' that Bayes' Theorem makes explicit and quantifiable, and is exactly what this calculator's default disease-testing example demonstrates.

Conclusion

Bayes' Theorem is most valuable when a prior probability is far from 50%, since that is exactly when intuition about test accuracy tends to mislead. This calculator makes that interaction explicit and quantifiable with a simple three-input form.