Bayes' Theorem Calculator

Bayes' Theorem Calculator

Calculate posterior probability using Bayes' Theorem. Understand how new evidence updates the probability of an event.

Last updated: March 2026

Enter Probabilities

Prior probability (0 to 1)

Likelihood (evidence given A)

Likelihood (evidence given not A)

Posterior Probability
16.102%
P(A|B) — Probability of A given evidence B

Calculation

P(¬A) = 1 - P(A) = 0.990000
P(B) = P(B|A) × P(A) + P(B|¬A) × P(¬A)
= 0.950000 × 0.010000 + 0.050000 × 0.990000
= 0.059000
P(A|B) = P(B|A) × P(A) / P(B)
= 0.950000 × 0.010000 / 0.059000
= 0.161017
P(B)
0.059000
Total probability of evidence
P(A|B)
0.161017
Posterior probability
Belief Change
15.1%
Percentage point shift

How Prior Belief Changes With Evidence

Prior BeliefWith Strong Evidence (P(B|A)=99%, P(B|¬A)=5%)With Weak Evidence (P(B|A)=60%, P(B|¬A)=40%)
1% (rare event)≈ 17%≈ 1.5%
50% (uncertain)≈ 95%≈ 60%
90% (very likely)≈ 99.4%≈ 95%

Strong evidence moves belief significantly; weak evidence moves it slightly. The more uncertain you start (50%), the more evidence shifts your belief.

What is Bayes' Theorem?

Bayes' Theorem is a mathematical formula that describes how to update probabilities as new evidence becomes available. It bridges our prior belief (before seeing evidence) with our posterior belief (after observing evidence), making it a cornerstone of probability, statistics, machine learning, and decision-making.

The theorem states: Posterior = (Likelihood × Prior) / Evidence. In practical terms, if you start with a belief that something is true (prior), then observe new data (evidence), Bayes' Theorem tells you how much to adjust your belief (posterior). The more reliable the evidence, the bigger the adjustment.

For example, medical testing: if you test positive for a rare disease, Bayes' Theorem calculates the real probability you have it—accounting for the test's accuracy and how rare the disease is. This often reveals that many positive tests are false positives if the disease is truly rare.

How to Use This Calculator

1

Enter P(A) — Your Prior Belief

Enter the probability of event A occurring before you see any evidence. This is your initial belief (e.g., 0.01 for a 1% chance).

2

Enter P(B|A) & P(B|¬A) — the Evidence Likelihoods

P(B|A): probability of seeing evidence B if A is true. P(B|¬A): probability of seeing evidence B if A is false. These represent how reliable the evidence is.

3

Read Your Posterior Probability

The result P(A|B) is your updated belief about A after observing evidence B. Compare it to your prior to see how much your belief changed.

The Formula:

P(A|B) = [P(B|A) × P(A)] / [P(B|A) × P(A) + P(B|¬A) × P(¬A)]
where P(¬A) = 1 - P(A)

Worked Example: Medical Testing

A patient tests positive for a rare disease. What's the real probability they have it?

Given:
Disease prevalence: 1 in 10,000 → P(A) = 0.0001
Test accuracy (sensitivity): 99% → P(+ | disease) = 0.99
False positive rate: 5% → P(+ | no disease) = 0.05
Calculation:
P(disease) = 0.0001
P(no disease) = 0.9999
P(+) = 0.99 × 0.0001 + 0.05 × 0.9999 = 0.050094
P(disease|+) = (0.99 × 0.0001) / 0.050094
= 0.0000099 / 0.050094 ≈ 0.00198 (0.198%)
Insight:
Even with a positive test, real probability is only ~0.2%

Despite a test that's 99% accurate, the patient's actual risk increased from 0.01% (prior) to only 0.2% (posterior). Why? The disease is so rare that false positives from the healthy population outnumber true positives.

Key lesson: When testing for rare events, most positive results are false when base rates are very low.

Frequently Asked Questions

Why does my posterior seem unintuitive?

When the prior (P(A)) is very low (rare event) and false positive rate (P(B|¬A)) is non-negligible, most positive results are false. This is the base rate fallacy—updating based only on test accuracy, ignoring base rates.

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

P(B|A) is likelihood: given A, what's the chance of B? P(A|B) is posterior: given B, what's the chance of A? Bayes' Theorem reverses the direction using priors and evidence.

Can probabilities be greater than 1 or negative?

No. All valid probabilities are in [0,1] (or 0–100%). If your calculator shows an error, check that inputs are in this range.

What if P(B) = 0?

This breaks Bayes' Theorem (division by zero). It means the evidence is impossible given both A and ¬A, which shouldn't happen in reality. Check your inputs.

How do I interpret a big difference between prior and posterior?

Large changes mean the evidence is strong and diagnostic. Small changes suggest weak evidence. Example: a 99% accurate test on a common condition produces large posterior shifts; on a rare condition, posterior shifts are minimal.

Can I use this for multiple pieces of evidence?

Yes, but it requires chaining: use posterior from round 1 as the prior for round 2. For many evidence pieces, sequential updating gets complex—use software like Bayesian networks.

What's the connection to machine learning?

Naive Bayes classifiers use Bayes' Theorem to assign data to categories. Bayesian networks represent probabilistic relationships. Many ML algorithms implicitly or explicitly use Bayesian inference.

Why is it called 'Bayes'?

Named after Rev. Thomas Bayes (1702–1761), who first formulated the theorem. He was an English statistician and theologian. The paper was published posthumously in 1763.

Related Tools