Bayes' theorem calculator

A classic case: a condition affects 1%, the test catches 90% and gives 9% false positives; how likely is a positive result to be real?

Loading the tool…

Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.

How to use it

  1. Enter prior p(a), p(b|a) true positive rate and p(b|not a) false positive rate.
  2. The result appears straight away and updates as you edit.
  3. Copy the result, or copy a link that keeps the same values to share it.

How it is calculated

P(B) = P(A) × P(B|A) + (1 - P(A)) × P(B|not A). Then P(A|B) = P(A) × P(B|A) ÷ P(B).

Example

Inputs: Prior P(A) = 1 %, P(B|A) true positive rate = 90 %, P(B|not A) false positive rate = 9 %. Result: P(A|B) updated probability: 9.174312%; P(B) chance of a positive: 9.81%; P(A|not B): 0.110877%.

Limits and caveats

  • The result depends entirely on the inputs, especially the prior.
  • Not a medical diagnosis tool; medical decisions belong to a doctor.

Questions about this tool

Why is P(A|B) low even with an accurate test?

When the condition is rare, false positives from the many healthy people outnumber true positives from the few who have it.

What is the difference between P(A|B) and P(B|A)?

P(B|A) is the chance of a positive test given the condition; P(A|B) is the chance of the condition given a positive. Mixing them up is a common mistake.

What does P(A|not B) mean?

The chance the condition is present despite a negative result, the false negative risk.