Skip to content
Calc.

Bayes' Theorem Calculator

Compute the posterior probability P(A|B) using Bayes' theorem. Use it when you want to update a prior belief about event A after observing new evidence B — common in medical testing, spam filtering, and risk analysis.

Last updated: September 2026

P(A|B) Posterior Probability

0.08333

Formula below · 2 sources (ocw.mit.edu, mathworld.wolfram.com) · Updated Sep 2026

Compare with similar

About this calculator

Bayes' theorem updates the probability of a hypothesis A after seeing evidence B:

P(A|B) = P(A) × P(B|A) ÷ P(B)

• P(A), the prior: how likely A was before the evidence. • P(B|A), the likelihood: how likely the evidence is if A is true (for a test, its sensitivity). • P(B): the overall probability of the evidence. If you know the false-positive rate P(B|not A) instead, compute it by the law of total probability: P(B) = P(B|A) × P(A) + P(B|not A) × (1 − P(A)).

The result, the posterior P(A|B), is the updated probability. Enter probabilities as decimals (1% = 0.01). The inputs must be consistent: P(B) can be no smaller than P(A) × P(B|A), or the posterior would exceed 1. The calculator also shows the false-positive rate your inputs imply.

The classic lesson is the base-rate effect: when A is rare, even an accurate test produces mostly false positives, because the few true positives are swamped by false positives from the much larger group without A.

How to use

Example (the defaults): a condition affects 1% of people, P(A) = 0.01. A test detects 90% of cases, P(B|A) = 0.9, and has a 10% false-positive rate, so P(B) = 0.9 × 0.01 + 0.1 × 0.99 = 0.108. Posterior: 0.01 × 0.9 ÷ 0.108 = 0.0833. A positive result means only about an 8.3% chance of having the condition. A second, independent positive test: use 0.0833 as the new prior. P(B) = 0.9 × 0.0833 + 0.1 × 0.9167 = 0.1667, and the posterior rises to 0.45.

Frequently asked questions

What is the difference between prior probability and posterior probability in Bayes' theorem?

The prior probability P(A) represents your belief in hypothesis A before any new evidence is observed. The posterior probability P(A|B) is your updated belief after taking new evidence B into account. Bayes' theorem provides the exact mathematical rule for performing this update. The difference between the two reflects how much the evidence shifts your belief — strong evidence causes a large shift, while weak evidence causes little change.

When should I use Bayes' theorem instead of classical probability?

Use Bayes' theorem whenever you have prior knowledge about a hypothesis and want to update that belief in light of new data. Classical probability treats all outcomes equally, but Bayesian reasoning incorporates prior information, making it ideal for medical diagnosis, fraud detection, and spam classification. It is especially powerful in situations where base rates matter — for example, a positive test for a rare disease is still unlikely to mean illness if the base rate is very low. Any time you need to reason about conditional relationships, Bayes' theorem is the right tool.

Why does a high-accuracy test sometimes give a misleading posterior probability?

This phenomenon — often called the base rate fallacy — occurs when the prior probability of a condition is very low. Even if a test is 99% accurate, a positive result may still be more likely a false positive than a true positive when the condition affects only 1 in 10,000 people. Bayes' theorem makes this explicit by forcing you to account for P(B), the total probability of a positive test across the entire population. Ignoring base rates leads to overconfidence in test results and is a common error in medical and legal reasoning.

Related calculators

Sources & references

How we check our calculators

Think a result is wrong? Report a problem with this calculator.