P|

Bayes' Theorem Calculator

Update a probability with new evidence: the posterior P(A | B) from the prior, the true positive rate and the false positive rate, also told as natural frequencies.

Statistics & ProbabilityRuns in your browser

Result…

%

How likely A is before the evidence. In a test example, how common the condition is in the group tested.

%

How often the evidence B shows up when A is true. For a test, its sensitivity.

I know the
%

How often B shows up when A is false.

The result told as counts: of this many people (or cases), how many…

 

…

How it's calculated

P(A | B) = P(B | A) × P(A) ÷ P(B)
P(B) = P(B | A) × P(A) + P(B | not A) × (1 − P(A)) · false positive rate = 1 − specificity
Posterior odds = prior odds × P(B | A) ÷ P(B | not A)

Bayes' theorem turns "how likely is the evidence if A is true" into "how likely is A now that I have seen the evidence". It needs three numbers: the prior P(A), how often the evidence B appears when A is true, and how often it appears anyway when A is false. The classic illustration is a screening test for a rare condition: with 1% prevalence, 90% sensitivity and a 9% false positive rate, only about 9% of people who test positive have the condition, because the many people without it produce more false positives than the few with it produce true ones. Natural frequencies tell the same thing as counts of people, which most readers find easier. The figures in the defaults are illustrative, not from any real test.

Your numbers, step by step

    About the Bayes' Theorem calculator

    This Bayes' theorem calculator updates a probability when new evidence arrives. Give it the prior, how likely A was before you looked, the true positive rate P(B | A), and the false positive rate P(B | not A) or the specificity, and it returns the posterior P(A | B): how likely A is now that B has been seen. The best-known use is reading a screening test, where a positive result for a rare condition often means less than people expect, but the same sum applies to spam filters, quality checks, forecasts and exam questions. Alongside the percentages it tells the result as natural frequencies, counts out of a group of 10,000 or any size you choose, which many people find easier to follow. It also gives P(B), P(A | not B) and the likelihood ratio, with each step shown. Test figures here are illustrative only.

    How to use it

    1. Enter “Prior probability P(A)” as a percentage: how common A is before the evidence.
    2. Enter “True positive rate P(B | A)”, the test's sensitivity in a medical-style example.
    3. Under “I know the”, pick “False positive rate” or “Specificity” and enter that figure.
    4. Read P(A | B), then the natural frequencies; change “Group size for natural frequencies” for other counts.

    Worked example

    Take an illustrative test with 1% prevalence, 90% sensitivity and a 9% false positive rate. P(B) = 0.9 × 0.01 + 0.09 × 0.99 = 0.0981, so P(A | B) = 0.009 ÷ 0.0981 = 9.17%. As counts: of 10,000 people, 100 have the condition and 90 of them test positive; of the 9,900 without it, 891 test positive. So only 90 of the 981 positives have the condition. A negative result leaves P(A | not B) at 0.111%.

    Updated

    Questions people ask

    What is the formula for Bayes' theorem?

    P(A | B) = P(B | A) × P(A) ÷ P(B), where P(B) = P(B | A) × P(A) + P(B | not A) × (1 − P(A)). The bottom line adds up every way B can happen: with A and without it.

    Why is a positive test for a rare condition often a false alarm?

    When a condition is rare, the large group without it produces more false positives than the small group with it produces true positives. In the example, 891 false positives outnumber 90 true ones, so P(A | B) is only about 9%.

    What is the difference between specificity and the false positive rate?

    Specificity is the share of people without A who correctly show no B; the false positive rate is the share who wrongly show B. They add up to 100%, so 91% specificity is a 9% false positive rate.

    What is the odds form of Bayes' theorem?

    Posterior odds = prior odds × likelihood ratio, where the likelihood ratio is P(B | A) ÷ P(B | not A). Odds of 0.10101 turn back into a probability as odds ÷ (1 + odds) = 9.17%; the odds calculator converts other forms.

    Can I use this to interpret my own medical test?

    No. The calculator shows how the sum works, but real test performance and your own prior risk depend on the test, the setting and your history. A doctor or other qualified health professional should interpret real results.

    More in Statistics & Probability