🧠 Bayes’ Theorem Calculator (Posterior Probability)

Why a positive test for a rare disease is often a false alarm — worked out with Bayes.

No ratings yet — be the first

Enter details

e.g. how common a condition is: 1% = 0.01
test sensitivity / true-positive rate
false-positive rate (1 − specificity)

Log in or create a free account to save your inputs and results, so you don't have to enter them again next time.🔒 No spam, ever. We never sell or share your details, and you can delete your history or account at any time. Privacy policy

Fill in the details and click Calculate to see your results.

Formula at a glance

Bayes’ Theorem Calculator: Bayes’ theorem — P(A|B) = P(B|A)·P(A) / P(B). Example: Rare condition, accurate test → P(A | B) — posterior: 0.161017 (16.1017%)
How the Bayes’ Theorem Calculator works: Bayes’ theorem — P(A|B) = P(B|A)·P(A) / P(B)

Rate this calculator

Was it useful? A quick star rating helps others — and you can leave a comment too.
Rate it: ★ ★ ★ ★ ★

📘 About the Bayes’ Theorem Calculator

Bayes’ theorem updates a probability when new evidence arrives. It answers questions like: if a test is 95% accurate and 1% of people have the condition, what is the chance that someone who tests positive really has it? Surprisingly often, the answer is low — because false positives from the healthy majority outnumber true positives.

Enter the prior and the two likelihoods. The calculator gives the posterior P(A|B), the overall probability of B, P(A | not B), the likelihood ratio, and a natural-frequency table out of 10,000 people that makes the result easy to explain.

🧮 Formula

Bayes’ theorem
P(A|B) = P(B|A)·P(A) / P(B)
Total probability
P(B) = P(B|A)·P(A) + P(B|¬A)·P(¬A)

✏️ Worked examples

Rare condition, accurate test

You enter
Prior P(A)0.01
P(B | A)0.95
P(B | not A)0.05
You get
P(A | B) — posterior0.161017 (16.1017%)
P(B) — overall chance of B0.059 (5.9%)
P(A | not B)0.00053135 (0.053135%)
Likelihood ratio P(B|A) ÷ P(B|not A)19
In 10,000 cases95 true positives and 495 false positives → 16.1% of positives are real

0.161017 (16.1017%).

Spam filter

You enter
Prior P(A)0.4
P(B | A)0.9
P(B | not A)0.02
You get
P(A | B) — posterior0.967742 (96.7742%)
P(B) — overall chance of B0.372 (37.2%)
P(A | not B)0.0636943 (6.36943%)
Likelihood ratio P(B|A) ÷ P(B|not A)45
In 10,000 cases3,600 true positives and 120 false positives → 96.77% of positives are real

0.967742 (96.7742%).

🧭 How to use this calculator

What you enter

  • Prior P(A)e.g. how common a condition is: 1% = 0.01
  • P(B | A)test sensitivity / true-positive rate
  • P(B | not A)false-positive rate (1 − specificity)

What you get

  • P(A | B) — posterior
  • P(B) — overall chance of B
  • P(A | not B)
  • Likelihood ratio P(B|A) ÷ P(B|not A)
  • In 10,000 cases

❓ Frequently asked questions

What is a prior probability?

Your probability before seeing the evidence — for a disease, its prevalence in the group tested.

Why is the posterior so low for rare diseases?

Because even a small false-positive rate applied to the large healthy group creates more false positives than there are true cases.

Where is Bayes’ theorem used?

Medical diagnosis, spam filters, machine learning, forensic evidence, A/B testing and updating forecasts.