Skip to content

Bayes' Theorem Calculator

Turn a prior probability and two conditional probabilities into the posterior P(A|B) — for example, the chance that someone with a positive test result really has the condition. You get Bayes' formula worked through with your numbers and a natural-frequency table that makes the answer intuitive.

What do you know?
Enter probabilities as

Fractions such as 1/250, and values with a % sign, also work.

Enter all three probabilities, each between 0 and 100% (or 0 and 1).

How to Use the Bayes' Theorem Calculator

  1. 1. Choose what you know. Usually the prior P(A), the probability of the evidence when A is true, P(B|A), and when A is false, P(B|not A). If you know the overall P(B) instead, switch to the second option.
  2. 2. Pick percentages or decimals. In percentage mode, type 1 for 1%; in decimal mode, 0.01. Fractions such as 1/250 work in either.
  3. 3. Read P(A|B). The posterior appears with P(B) and the probabilities after a negative result, P(A|not B) and P(not A|not B).
  4. 4. Check the table of people. The same numbers as counts out of 1,000, 10,000 or 100,000 people show where the answer comes from.

Bayes' Theorem

Bayes' theorem

P(A|B) = P(B|A) × P(A) ÷ P(B)

Total probability

P(B) = P(B|A) × P(A) + P(B|not A) × (1 − P(A))

P(A) is the prior — how likely A was before you saw the evidence. P(B|A) is the likelihood of the evidence if A is true, and P(B|not A) its likelihood if A is false. P(B) is how often the evidence turns up overall. The result, P(A|B), is the posterior: how likely A is now that you have seen B. In a diagnostic test, these are the prevalence, the sensitivity, the false-positive rate (1 − specificity) and the positive predictive value.

The Classic Medical-Test Example

A condition affects 1% of people. A screening test detects it 90% of the time (sensitivity) but also comes back positive for 9% of people without it. Someone tests positive. How likely is it that they have the condition? Many people guess close to 90%. Bayes' theorem says: P(B) = 0.9 × 0.01 + 0.09 × 0.99 = 0.0981, so P(A|B) = 0.009 ÷ 0.0981 = 9.17%.

The same test in 10,000 people
Test positiveTest negativeTotal
Has the condition9010100
Does not have it8919,0099,900
Total9819,01910,000

Counted as people, the answer is easy to see: of the 981 positive results, only 90 come from people with the condition, and 90 ÷ 981 = 9.17%. The test is not bad — the condition is rare, so the 9% of false positives among 9,900 healthy people swamps the true positives among 100 sick ones. Psychologists Gerd Gigerenzer and Ulrich Hoffrage (1995) showed that presenting problems as natural frequencies like these makes people reason far more accurately than presenting probabilities.

Why the Prior Matters So Much

Keep the same test but apply it where the condition affects 10% of patients — a specialist clinic rather than a population screen — and a positive result means a 52.63% chance of having it. Or retest: if the first positive raises the probability to 9.17%, use that as the new prior, and a second positive result (from an independent test with the same accuracy) lifts it to 50.25%. That is why screening programmes confirm positives with a second test, and why the same evidence means different things in different populations.

Ignoring the prior is the base-rate fallacy, and it is not only a medical problem. Spam filters, forensic evidence, fraud alerts and machine-learning classifiers all face it: when the thing you are looking for is rare, most alarms are false even when the detector is good.

Frequently Asked Questions

What is Bayes' theorem in simple terms?
It is a rule for updating a probability when you get new evidence. Start with how likely something was beforehand (the prior), weigh how much more likely the evidence is if it is true than if it is false, and you get the updated probability (the posterior). The formula is P(A|B) = P(B|A) × P(A) ÷ P(B).
What is the difference between P(A|B) and P(B|A)?
They answer opposite questions. P(B|A) is the chance of a positive test if you have the condition — the sensitivity, 90% in the example. P(A|B) is the chance you have the condition if you test positive — 9.17% in the example. Confusing the two — the fallacy of the transposed conditional, or in court the prosecutor's fallacy — is one of the most common errors in reasoning about evidence.
How do I find P(B) for Bayes' theorem?
Usually you calculate it with the law of total probability: P(B) = P(B|A) × P(A) + P(B|not A) × (1 − P(A)). That is the first input mode here. If you already know P(B) — from survey data, for instance — use the second mode, and the calculator works out the implied P(B|not A).
What are sensitivity and specificity?
Sensitivity is the proportion of people with the condition who test positive, P(positive|condition). Specificity is the proportion of people without it who test negative, P(negative|no condition). The false-positive rate this calculator asks for is 1 − specificity, so a test with 91% specificity has a false-positive rate of 9%.
What is the base-rate fallacy?
It is judging the probability of something from how well the evidence fits it while ignoring how common it is in the first place. With a rare condition, even a positive result from an accurate test usually comes from someone without the condition, because there are so many more of them.
Can I use Bayes' theorem with more than two outcomes?
Yes. With several mutually exclusive hypotheses A₁, A₂, …, the denominator becomes the sum of P(B|Aᵢ) × P(Aᵢ) over all of them. This calculator handles the common two-outcome case — A or not A — which covers diagnostic tests, screening and most textbook problems.

Related Tools

More in Statistics Calculators

See all Statistics Calculators