Bayes' Theorem Calculator
Written by Thierno Sadou Diallo, formula verified per our methodology • Last checked on 9/10/2026
Bayes' theorem calculates P(A|B) = [P(B|A) × P(A)] ÷ P(B). For a medical test with a prevalence of 1%, a sensitivity of 90%, and a total probability of a positive result of 10%, the probability of actually having the disease given a positive test is only 9%.
Explanation
Bayes' theorem lets you "reverse" a conditional probability: from P(B|A) (the probability of B if A is true) and the prior probability of A, it calculates P(A|B) (the probability of A given that B occurred). It is one of the most counterintuitive results in probability, notably applied to medical screening tests: even a very sensitive test (which correctly detects 90% of real cases) can give a surprisingly low probability of actual disease after a positive result, if the tested disease is rare in the population. In the example above, despite a 90% sensitivity, a person who tests positive has only a 9% chance of actually being ill, because the disease is rare (1% prevalence) and false positives, even few in proportion, then become more numerous in absolute terms than true positives. This is called the false positive paradox, a classic illustration of the importance of accounting for the prior probability (P(A)) and not just a test's apparent reliability. P(B), the total probability of event B, must include both true positives and false positives (P(B) = P(B|A)×P(A) + P(B|not A)×P(not A)); this calculator asks for this value directly as input rather than recomputing it, so it stays usable even when P(B|not A) is not known separately. For a simple probability from favorable and possible cases rather than a conditional probability, see our simple probability calculator.
Example: prevalence 1%, sensitivity 90%, total probability of positive 10%
Inputs
P(A) = 1%. P(B|A) = 90%. P(B) = 10%.
Calculation
P(A|B) = (0.90 × 0.01) ÷ 0.10 = 0.009 ÷ 0.10 = 0.09, that is 9%.
Result
Given a positive test, the probability of actually being ill is only 9%.
Frequently asked questions
Why is the probability obtained so different from the test's sensitivity?
Because sensitivity (P(B|A) = 90%) answers a different question: "if I am ill, what is the probability that the test is positive?". Bayes' theorem answers the reverse question, the one that really matters to a patient who tests positive: "given that my test is positive, what is the probability that I am actually ill?". These two probabilities are only equal in special cases, and the gap is larger the rarer the disease.
Where does the value of P(B), the total probability of a positive result, come from?
P(B) combines the true positives and false positives of the whole test: P(B) = P(B|A) × P(A) + P(B|not A) × P(not A), where P(B|not A) is the false positive rate (1 minus the test's specificity). This calculator asks for P(B) directly, already calculated, to stay simple to use even if you only know that overall result and not the detail of the test's specificity.
Does this theorem apply only to medical tests?
No, it is a general result of probability, used well beyond the medical field: spam filters (probability that a message is spam given that it contains certain words), fault diagnosis, pattern recognition, or any reasoning that updates a prior probability in light of newly observed information.