Home · Statistics · Probability & Combinatorics · Bayes' Theorem Calculator

Bayes' Theorem Calculator

Bayes' theorem: update the probability of A after observing B, from the prior P(A) and the likelihoods of B under A and under not-A. All inputs in percentages.

Your figures

Example result — edit the figures to make it yours

77.42

P(A | B)

P(not A | B)22.58 %

What this calculator does

Bayes' theorem: update the probability of A after observing B, from the prior P(A) and the likelihoods of B under A and under not-A. All inputs in percentages. Every figure on this page is computed from the standard definition stated below — the same definition used in textbooks and reference tables — with no hidden rounding steps, and the method notes name the exact convention where more than one exists.

The formula and method

P(A | B) = P(A)·P(B|A) / [ P(A)·P(B|A) + P(not A)·P(B|not A) ]; in percent, = pa × pba / (pa × pba + (100 − pa) × pbn) × 100

All inputs are percentages from 0 to 100: pa is the prior probability of A before B is observed, pba is the chance of seeing B when A is true, and pbn is the chance of seeing B when A is false; P(not A) is 100 − pa.

The denominator is the total probability of B, split over the two ways B can arise — with A and without A — by the law of total probability.

The result is the posterior probability of A given B. A rare prior needs a very discriminating B (pba far above pbn) to produce a high posterior, which is why screening tests for rare conditions yield many false positives.

Worked example

With the example inputs this page opens with (prior probability p(a) (%) 30, p(b | a) (%) 80, p(b | not a) (%) 10), the result is 77.42 — p(a | b). Change any figure and the result updates with the same formula.

Quick reference

Quick reference — varying prior probability p(a) (%)
Prior probability P(A) (%)P(A | B)
1558.54
2471.64
3077.42
37.582.76
4586.75
6092.31

Computed with the same formulas as the calculator above — enter any values there for figures beyond this table.

Common questions

Why does a positive test for a rare condition still leave doubt?

If the condition affects 1% of people, the false positives from the healthy 99% can outnumber the true positives from the ill 1%, even with an accurate test. Bayes' theorem weighs both groups, which the prior pa and the false-positive rate pbn capture.

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

P(B|A) is the likelihood — how often the evidence appears when the hypothesis holds — and is usually measured directly. P(A|B) is the posterior — how believable the hypothesis is after the evidence — and is what Bayes' theorem computes from the likelihood and the prior.

How does the Bayes' Theorem Calculator work?

Bayes' theorem: update the probability of A after observing B, from the prior P(A) and the likelihoods of B under A and under not-A. All inputs in percentages. P(A) (%) · P(B | A) (%) · P(B | not A) (%) → P(A | B) (%). The result updates as you type, and the formula and method on this page state the exact definitions used, so you can reproduce the calculation by hand.

What inputs does the Bayes' Theorem Calculator need?

P(A) (%) · P(B | A) (%) · P(B | not A) (%) → P(A | B) (%). Invalid entries — such as a zero denominator, an out-of-range value or a malformed list — produce a plain-language message instead of a misleading number.