Bayes' Theorem Calculator
Bayes' theorem updates a probability when new evidence arrives. Find P(A|B) from P(B|A), P(A) and P(B) — or run the medical-test version, where sensitivity, specificity and prevalence give the chance that a positive result is real.
Choose a calculation type, enter your probabilities, and get the posterior as a decimal, a percentage and a “1 in N” figure instantly.
Result
How It Works
Bayes' theorem tells you how to update a belief when new evidence arrives: P(A|B) = P(B|A) × P(A) ÷ P(B). P(A) is the prior — what you believed before the evidence. P(B|A) is the likelihood — how probable the evidence is if A is true. P(B) is the total probability of the evidence. Dividing by P(B) rescales the answer so it is a proper probability. The result, P(A|B), is the posterior — your updated belief after seeing the evidence.
The medical-test mode is the same theorem with the terms filled in from test characteristics. The chance of having the disease after a positive test is P(disease | positive) = sensitivity × prevalence ÷ (sensitivity × prevalence + false-positive rate × (1 − prevalence)), where the false-positive rate is 1 − specificity. The denominator is the total probability of a positive result: true positives plus false positives. When the disease is rare, the false positives can outnumber the true ones many times over — which is why the answer is often far lower than people expect. The calculator also shows the breakdown per 10,000 people, so you can see exactly where the numbers come from.
Worked Example
Direct: P(B|A) = 0.8, P(A) = 0.3, P(B) = 0.5. The posterior is 0.8 × 0.3 ÷ 0.5 = 0.4800 (48.00%), or 1 in 2.08 — the evidence raised the probability from 30% to 48%. Medical test: a disease with 1% prevalence, a test with 99% sensitivity and 95% specificity. A positive result gives P(disease | positive) = 0.1667 (16.67%), or 1 in 6. Out of 10,000 people: 99 true positives, 1 false negative, 495 false positives and 9,405 true negatives — the 495 false positives swamp the 99 true ones. A negative result is reassuring: P(disease | negative) = 0.0001 (0.01%).
Assumptions
- Every input is a probability. All values must be between 0 and 1. A value outside that range is rejected with a clear message.
- P(B) must be greater than 0. If the evidence is impossible, Bayes' theorem has nothing to divide by — the calculator shows a clear message instead of a number.
- The inputs must be consistent. P(B) can never be smaller than P(B|A) × P(A), because the evidence must be at least as likely as the evidence-and-A together. Inconsistent inputs are rejected with the minimum P(B) shown.
- Test accuracy is assumed constant. The medical-test mode assumes sensitivity and specificity are the same for everyone tested. In practice they can vary by age, symptoms and test batch.
- Prevalence is the pre-test probability. The 1% in the example is the share of the population with the disease. For a person with symptoms or risk factors, the pre-test probability is higher — and so is the posterior.
- A screening result is not a diagnosis. This calculator is for education and quick checks — it is not a substitute for professional statistical advice, and any test result should be followed up with a qualified clinician.
Last reviewed: 15 November 2026.
Built and tested by SumKitTool — see how we check our numbers.
How to Use This Calculator
Pick a calculation type, enter your probabilities, and the result updates live as you type.
- Choose the calculation type — direct Bayes' theorem with three probabilities, or the medical-test version with sensitivity, specificity and prevalence.
- Enter your probabilities — each between 0 and 1. For the medical test, the false-positive rate is 1 minus the specificity you enter.
- Read the answer — the posterior as a decimal, a percentage and a “1 in N” figure, plus (for medical tests) the per-10,000 breakdown and the probability after a negative result.
The Reset button restores the worked example (P(B|A) = 0.8, P(A) = 0.3, P(B) = 0.5 — P(A|B) = 0.4800).
Tips and Practical Advice
- Never ignore the base rate. A 99% accurate test on a 1%-prevalence disease still gives a positive result that is wrong five times out of six. The prior matters as much as the test.
- Read the per-10,000 breakdown. Natural frequencies — 99 true positives against 495 false positives — make the answer intuitive in a way percentages often don’t.
- A negative result is usually very reassuring. With a sensitive test, P(disease | negative) is tiny — 0.01% in the worked example. That is the number to look at after a negative result.
- Check consistency before trusting a direct calculation. If P(B) is smaller than P(B|A) × P(A), the inputs contradict each other and no posterior exists — the calculator tells you the minimum P(B) that would make sense.
Frequently Asked Questions
What is Bayes' theorem?
Bayes' theorem updates a probability when new evidence arrives: P(A|B) = P(B|A) × P(A) ÷ P(B). P(A) is what you believed before the evidence, P(B|A) is how likely the evidence is if A is true, and P(B) is how likely the evidence is overall. The result, P(A|B), is your updated belief. For example, with P(B|A) = 0.8, P(A) = 0.3 and P(B) = 0.5, the posterior is 0.8 × 0.3 ÷ 0.5 = 0.4800 — the evidence raised the probability from 30% to 48%.
Why is the medical-test answer so much lower than the test's accuracy?
Because of the base rate: when a disease is rare, most positive results are false positives. With a 1% prevalence, a 99% sensitive test and a 95% specific test, out of 10,000 people there are 99 true positives but 495 false positives — so a positive result means only a 16.67% chance of actually having the disease, or 1 in 6. The test is accurate, but the disease is rare, and the rare cases are swamped by the false alarms from the 9,900 healthy people. This is the base-rate fallacy, and it is why a positive screening result always needs a follow-up test.
What is the difference between sensitivity and specificity?
Sensitivity is the test's ability to find the disease: P(positive | disease). A 99% sensitive test catches 99 out of 100 diseased people and misses 1. Specificity is the test's ability to clear healthy people: P(negative | no disease). A 95% specific test correctly clears 95 out of 100 healthy people and falsely flags 5. A test can be highly sensitive but poorly specific, or the other way round — and the posterior probability depends on both, plus the prevalence.
What does '1 in N' mean?
It is the same probability written as odds-style phrasing: how many people, on average, you would need for one to have the outcome. A posterior of 16.67% is 1 in 6 — roughly one person in six with a positive test actually has the disease. A posterior of 48.00% is 1 in 2.08. The phrasing is often easier to picture than a decimal or a percentage, especially for small probabilities.
Last updated: