Bayes Theorem Calculator

Last Updated: June 29, 2026

Calculate the posterior probability of an event using Bayes’ Theorem from a prior probability, a likelihood, and the evidence.

How likely A is before any evidence. Required.
Chance of B when A is true (test sensitivity). Required.
Overall chance of observing B. Required.
Chance of B when A is false (false positive rate). Required.

Bayes Theorem Formula

Bayes Theorem updates the probability of an event A after you observe evidence B. The calculator uses one of two equivalent forms.

P(A|B) = P(B|A) * P(A) / P(B)

When you do not know the overall evidence probability P(B) directly, expand it with the law of total probability:

P(B) = P(B|A) * P(A) + P(B|A') * P(A')

Where:

  • P(A|B) is the posterior probability, the chance A is true after seeing B.
  • P(A) is the prior probability of A before any evidence.
  • P(B|A) is the likelihood, the chance of seeing B when A is true.
  • P(B) is the evidence, the overall chance of seeing B.
  • P(B|A’) is the chance of seeing B when A is false. A’ means not A.
  • P(A’) equals 1 – P(A), the chance A is false.

The first mode divides the joint probability P(B|A) * P(A) by the evidence P(B) that you supply. The total probability mode builds P(B) for you from the prior, the likelihood, and the false positive rate P(B|A’). Use that second mode for medical tests and similar problems where you know the test accuracy but not the overall positive rate.

What Each Probability Means

TermSymbolMeaning
PriorP(A)Belief in A before evidence, often the base rate.
LikelihoodP(B|A)Chance of the evidence when A is true. For a test, the sensitivity.
False positiveP(B|A’)Chance of the evidence when A is false.
EvidenceP(B)Total chance of the evidence across all cases.
PosteriorP(A|B)Updated belief in A after seeing the evidence.

A small prior keeps the posterior low even when a test is accurate. The table below uses a 99% sensitivity test with a 5% false positive rate at three different base rates.

Prior P(A)Sensitivity P(B|A)False positive P(B|A’)Posterior P(A|B)
1%99%5%16.7%
5%99%5%51.0%
10%99%5%68.8%

Example Problems

Example 1: Standard form. You know P(A) = 0.3, P(B|A) = 0.6, and P(B) = 0.4. Apply the formula:

P(A|B) = (0.6 * 0.3) / 0.4 = 0.18 / 0.4 = 0.45. The posterior probability is 0.45, or 45%.

Example 2: Total probability form. A disease affects 1% of people, so P(A) = 0.01. A test catches it 90% of the time, so P(B|A) = 0.9, and it gives a false positive 8% of the time, so P(B|A’) = 0.08. First find the evidence:

P(B) = 0.9 * 0.01 + 0.08 * 0.99 = 0.009 + 0.0792 = 0.0882. Then P(A|B) = 0.009 / 0.0882 = 0.102, or about 10.2%. A positive test still means only a 10% chance of disease because the base rate is so low.

FAQ

What is the posterior probability? The posterior, P(A|B), is the probability that A is true once you have accounted for the evidence B. It is the main output of Bayes Theorem and replaces the prior as your updated belief.

Why is the result low even when the test is accurate? When the prior probability is small, most positive results come from the large group that does not have the condition. Even a highly accurate test produces many false positives in that group, which pulls the posterior down.

What is the difference between P(B|A) and P(A|B)? P(B|A) is the chance of the evidence given that A is true, such as a test reading positive when someone has a disease. P(A|B) reverses the direction and gives the chance A is true given the evidence. Bayes Theorem converts one into the other.

Bayes Theorem Calculator