Skip to content
FiftyCalc Free calculators for all 50 states

Bayes' Theorem Calculator

Test cases replayed : 3 of 3 match · Methodology · No outside source listed

Enter the prior probability of A and the probability of the evidence B with and without A, as numbers between 0 and 1.

Result

Sample figures

P(A | B), posterior probability—

P(B), total probability of B —

  • P(A | not B)—

Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.

Bayes' Theorem Calculator

Prior probability P(A) (0 to 1): enter a number from 0 to 1. Prefilled example: 0.01.

P(B | A), probability of B when A is true: enter a number from 0 to 1. Prefilled example: 0.9.

P(B | not A), probability of B when A is false: enter a number from 0 to 1. Prefilled example: 0.05.

How to use this calculator

Fill in the fields in this order; each step takes you to its field.

  1. Prior probability P(A) (0 to 1): enter a number from 0 to 1.
  2. P(B | A), probability of B when A is true: enter a number from 0 to 1.
  3. P(B | not A), probability of B when A is false: enter a number from 0 to 1.
  4. Read the result: P(A | B), posterior probability; the panel also shows P(B), total probability of B and P(A | not B).

How this calculator works

Bayes' theorem: P(A | B) = P(B | A) × P(A) ÷ P(B), where the law of total probability gives P(B) = P(B | A) × P(A) + P(B | not A) × (1 − P(A)).

In a screening example, A is having the condition, B a positive result, P(B | A) the sensitivity and P(B | not A) the false positive rate (1 − specificity).

The formula

  1. Pb=pba×pa+p×(1−pa)
  2. Pab=pba×paPb
Symbols used in the formula
SymbolMeaning
paPrior probability P(A) (0 to 1)
pbaP(B | A), probability of B when A is true
pP(B | not A), probability of B when A is false
PbP(B), total probability of B
PabP(A | B), posterior probability

Worked example

Prior probability P(A) (0 to 1)0.01
P(B | A), probability of B when A is true0.9
P(B | not A), probability of B when A is false0.05
P(B), total probability of B0.0585
P(A | not B)0.0011
  1. Pb=0.9×0.01+0.05×(1−0.01)=0.0585
  2. Pab=0.9×0.010.0585=0.153846

P(A | B), posterior probability 0.1538

Each step uses the unrounded value of the step before it; figures on this page are rounded for display.

Frequently asked questions

If 1% have a condition and a test is 90% sensitive with 5% false positives, what does a positive mean?

P(A | B) = 0.009 ÷ 0.0585 ≈ 0.1538: about a 15% chance, because false positives outnumber true ones.

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

They answer different questions and are usually different numbers; Bayes' theorem converts one into the other using P(A) and P(B).

Questions answered

Related calculators