Skip to content
Omnikalc

Bayes' theorem calculator: update a probability with new evidence

Combine a prior probability with how likely the evidence is when the hypothesis is true or false to get the posterior probability.

Updated on
Your inputs
%

Value out of range

%

Value out of range

%

Value out of range

Results

Posterior P(A | B)

9.17%

P(B)
9.81%
P(A | not B)
0.11%
Likelihood ratio P(B|A) ÷ P(B|not A)
10.00

Updating beliefs with evidence

Bayes’ theorem tells you how to revise the probability of a hypothesis when new evidence arrives. It combines what you believed before (the prior) with how likely the evidence is if the hypothesis is true or false.

The formula

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

with P(B) = P(B | A) × P(A) + P(B | not A) × P(not A).

  • P(A): prior probability of the hypothesis.
  • P(B | A): probability of the evidence if A is true.
  • P(B | not A): probability of the evidence if A is false.
  • P(A | B): posterior probability, after seeing the evidence.

Worked example: a screening test

A disease affects 1% of people. A test detects it 90% of the time and gives a false positive 9% of the time in healthy people. You test positive. What is the chance you have the disease?

  1. P(B) = 0.90 × 0.01 + 0.09 × 0.99 = 0.009 + 0.0891 = 9.81%.
  2. P(A | B) = 0.009 ÷ 0.0981 ≈ 9.2%.

Despite the positive test, the chance of disease is only about 9%. Out of 1,000 people, 9 sick people test positive, but so do 89 healthy ones.

The same example as counts

Test positive Test negative Total
Sick 9 1 10
Healthy 89 901 990
Total 98 902 1,000

Thinking in natural frequencies like this makes Bayes’ theorem much easier to grasp, and studies show doctors and patients reason better with counts than with percentages.

The likelihood ratio

The ratio P(B | A) ÷ P(B | not A), here 0.90 ÷ 0.09 = 10, measures how strongly the evidence favors A. In odds form:

posterior odds = prior odds × likelihood ratio

Prior odds of 1 to 99 times 10 give posterior odds of 10 to 99, or about 9.2%.

Common mistakes

  • Base rate neglect: ignoring the prior and treating P(B | A) as if it were P(A | B). This is the classic error behind overconfident readings of tests, alarms and forensic evidence.
  • The prosecutor’s fallacy: confusing “the chance of this evidence if the defendant is innocent” with “the chance the defendant is innocent given the evidence”.
  • Overconfident priors: a prior of 0 or 100% can never be changed by evidence.

Applying it again

After a second independent test, the posterior from the first becomes the new prior. Two positive results raise the probability far more than one, which is why confirmatory testing is standard practice.

Frequently asked questions

What is Bayes' theorem?

P(A | B) = P(B | A) × P(A) ÷ P(B). It updates the probability of a hypothesis A after observing evidence B, combining the prior probability with how likely the evidence is under each hypothesis.

Why is a positive test often wrong for a rare disease?

Because false positives from the large healthy group can outnumber true positives. With 1% prevalence, 90% sensitivity and a 9% false positive rate, only about 9% of people who test positive actually have the disease.

What is P(B)?

The overall probability of the evidence: P(B) = P(B | A) × P(A) + P(B | not A) × P(not A). In the example, 0.9 × 0.01 + 0.09 × 0.99 = 9.81%.

Where is Bayes' theorem used?

Medical diagnosis, spam filters, search and rescue, machine learning, forensic evidence and any situation where a belief is updated as new information arrives.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.