About the Bayes' Theorem Calculator
This Bayes' theorem calculator updates a probability when new evidence arrives. Enter how likely an event A was before you looked at the evidence (the prior), how often the evidence B shows up when A is true (the sensitivity or hit rate), and how often B shows up when A is false (the false positive rate). It returns the posterior probability P(A|B), the overall chance of seeing the evidence P(B), the probability of A after a negative result, and the positive and negative likelihood ratios.
It is built for statistics students working through textbook problems, analysts reasoning about diagnostic tests, spam filters, fraud flags or quality checks, and anyone who wants to see why a 90%-accurate test can still be wrong most of the time when the condition is rare. A natural-frequency table re-expresses everything as counts out of 10,000 cases, which is the easiest way to explain the result to someone else.
The calculator treats A and "not A" as the only two possibilities, so P(B) comes from the law of total probability. All three inputs are percentages between 0 and 100. It is a teaching and reasoning aid, not a substitute for professional interpretation of a real medical or legal test.
With the default inputs, the posterior p(a | b) is 9.17%. Change any value above to recalculate instantly.
How to use the bayes' theorem calculator
- 1Enter the prior probability of A — the base rate before any evidence.
- 2Enter P(B | A), how often the evidence appears when A is true.
- 3Enter P(B | not A), how often the evidence appears when A is false (100% − specificity).
- 4Read the posterior P(A | B) and the chance of A after a negative result.
- 5Use the 10,000-case table to explain the result in plain counts.
Formula and method
Bayes' theorem reverses a conditional probability. You usually know how often the evidence appears when A is true, P(B|A), but you want the probability that A is true now that you have seen the evidence, P(A|B). Multiply the prior P(A) by the likelihood P(B|A) and divide by the total probability of the evidence, P(B).
P(B) comes from the law of total probability: the evidence can appear either because A is true (true positives) or because A is false and the evidence fired anyway (false positives). When A is rare, the second group can dominate, which is why the posterior can be far lower than the sensitivity. In odds form, posterior odds = prior odds × LR+, where LR+ = P(B|A) ÷ P(B|¬A).
- P(A)
- Prior probability (base rate) of A
- P(B|A)
- Likelihood: probability of evidence B when A is true (sensitivity)
- P(B|¬A)
- Probability of evidence B when A is false (false positive rate)
- P(A|B)
- Posterior probability of A after observing B
- LR+
- Positive likelihood ratio, P(B|A) ÷ P(B|¬A)
Worked examples
Rare condition, 90% sensitive test
With a 1% base rate, 90 of 10,000 people have the condition and test positive, while 9% of the 9,900 without it — 891 people — also test positive. So only 90 of 981 positives are true: P(A|B) = 0.009 ÷ 0.0981 ≈ 9.17%.
Screening test: 0.5% prevalence, 99% sensitivity, 5% false positives
P(B) = 0.005 × 0.99 + 0.995 × 0.05 = 0.0547. The posterior is 0.00495 ÷ 0.0547 ≈ 9.05%, so even a very sensitive test gives mostly false positives at a 0.5% base rate, although a negative result (LR− ≈ 0.0105) almost rules the condition out.
Spam filter: a word appears in 25% of spam and 2% of normal mail
If 40% of mail is spam, P(word) = 0.4 × 0.25 + 0.6 × 0.02 = 0.112, and P(spam | word) = 0.1 ÷ 0.112 ≈ 89.3%. Without the word, the spam probability only drops to about 33.8%, because most spam does not contain it.
Frequently asked questions
What is Bayes' theorem in simple terms?+
Bayes' theorem tells you how to update the probability of a hypothesis when you see new evidence. Start with the prior, multiply by how likely the evidence is if the hypothesis is true, and divide by how likely the evidence is overall.
Why is a positive result from an accurate test often wrong?+
When a condition is rare, the many people without it produce more false positives than the few people with it produce true positives. With a 1% base rate and a 9% false positive rate, about 9 out of 10 positives are false even at 90% sensitivity.
What is the difference between P(A|B) and P(B|A)?+
P(B|A) is the chance of the evidence given the hypothesis, such as a test detecting a disease that is present. P(A|B) is the chance of the hypothesis given the evidence. Confusing them is called the base-rate fallacy or prosecutor’s fallacy.
How do I get the false positive rate from specificity?+
The false positive rate is 100% minus specificity. A test with 95% specificity has a 5% false positive rate, so enter 5 in the P(B | not A) field.
What is a likelihood ratio?+
The positive likelihood ratio is sensitivity divided by the false positive rate. It tells you how much a positive result multiplies the odds of A. An LR+ of 10 turns prior odds of 1:99 into posterior odds of 10:99.
Can I chain Bayes updates for two pieces of evidence?+
Yes, if the pieces of evidence are conditionally independent given A. Use the posterior from the first update as the prior for the second, then run the calculator again with the second test’s rates.