Bayes’ Theorem Calculator

Compute the posterior probability P(A|B) from the prior P(A), the evidence P(B), and the likelihood P(B|A).

Inputs

Probability of A before seeing evidence (0 to 1).

Overall probability of observing B (0 to 1).

Probability of B given A is true (0 to 1).

Result

Loading calculator…

How to use this calculator

  • Enter the prior probability P(A) — the base rate before evidence.
  • Enter the likelihood P(B|A) — how likely the evidence is when A holds.
  • Enter the overall evidence probability P(B).
  • Read the posterior P(A|B), your updated probability after the evidence.

About this calculator

Bayes’ theorem updates a probability in light of new evidence. It combines three ingredients: the prior P(A), your belief that A is true before seeing the evidence; the likelihood P(B|A), how probable the evidence B is when A is true; and the overall probability of the evidence P(B). The posterior P(A|B) — your updated belief after seeing B — equals P(B|A) times P(A), divided by P(B). The classic illustration is medical testing: even a 90%-accurate test for a disease that affects only 1% of people yields a surprisingly low probability of actually having the disease given a positive result, because the rare base rate dominates. This calculator makes that base-rate effect explicit by showing the joint probability and the final posterior.

How it works — the formula

P(A|B) = P(B|A) · P(A) ÷ P(B) (law of total probability: P(B) = P(B|A)P(A) + P(B|¬A)P(¬A))

The posterior is the joint probability of A and B divided by the total probability of B, rescaling the prior by how consistent the evidence is with A.

Worked examples

Example 1
Disease test: P(A)=0.01, P(B|A)=0.9, P(B)=0.05
Inputs:
pa=0.01, pba=0.9, pb=0.05
Output:
P(A|B) = 0.18 (18%)
Example 2
P(A)=0.5, P(B|A)=0.8, P(B)=0.6
Inputs:
pa=0.5, pba=0.8, pb=0.6
Output:
P(A|B) = 0.667
Example 3
P(A)=0.3, P(B|A)=0.5, P(B)=0.4
Inputs:
pa=0.3, pba=0.5, pb=0.4
Output:
P(A|B) = 0.375

Limitations

  • Requires P(B) directly; compute it via total probability if you only have the false-positive rate.
  • Garbage-in: an inaccurate prior or likelihood gives a misleading posterior.
  • Assumes the three inputs are mutually consistent probabilities.

A mathematical update rule; the quality of the answer depends on the quality of the inputs.

Frequently asked

What is Bayes’ theorem?+
It is the rule for updating a probability with new evidence: P(A|B) = P(B|A)·P(A) ÷ P(B). It converts a prior belief into a posterior belief by weighting it with how well the evidence fits.
What is the difference between prior and posterior?+
The prior P(A) is your probability for A before observing the evidence; the posterior P(A|B) is your revised probability after observing B. Bayes’ theorem is the bridge between them.
Why is the result so low in the disease-test example?+
Because of the base rate. If only 1% of people have a disease, even a highly accurate positive test mostly flags the much larger healthy group's false positives. The rare prior P(A) keeps the posterior low — a famous example of base-rate neglect.
How do I find P(B) if I do not have it directly?+
Use the law of total probability: P(B) = P(B|A)·P(A) + P(B|not A)·P(not A). If you know the false-positive rate P(B|not A), you can compute P(B) and then apply Bayes’ theorem.
What is the likelihood P(B|A)?+
It is the probability of seeing the evidence B assuming A is true — for a medical test, the true-positive rate (sensitivity). It is not the same as P(A|B), the thing you are solving for; confusing the two is a common error.
Must all the inputs be between 0 and 1?+
Yes. They are probabilities, so each must lie in [0, 1]. Additionally P(B) should be at least P(B|A)·P(A) for the inputs to be mutually consistent.

Related calculators

More tools you might like

Hand-picked tools that pair well with this one — same audience, same intent.