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).
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.