Skip to content
Calixo

Bayes Theorem Calculator with Examples

Update a probability based on new evidence — Bayes' theorem, the mathematical foundation behind medical testing, spam filters, and every 'given what we now know' probability question.

Inputs

%
%

%
%

%
%

Saved Scenarios

— select 2+ to compare
Inputs updated · Results recalculated · Just now

P(A|B) — Updated Probability

9.00%

Spark says

How it's calculated
Mathematical study scene with open book, graph paper, and pen for learning and homework.
Photo by Lum3n on Pexels
Hand writing mathematical equations on a chalkboard in a classroom setting.
Photo by Monstera Production on Pexels

Formula

P(AB)=P(BA)P(A)P(B)P(A|B) = \dfrac{P(B|A)\,P(A)}{P(B)}
P(A)
— The prior probability of A, before observing evidence B
P(A|B)
— The posterior probability of A, updated after observing B

What is the Bayes Theorem Calculator with Examples?

This calculator applies Bayes' theorem to update a probability based on new evidence — finding P(A|B), the probability that A is true given that B has been observed, from the prior probability of A and how likely B is under each scenario.

Use this when interpreting a medical test result correctly, accounting for a condition's base rate, evaluating how strongly new evidence should actually shift a prior belief, or understanding why a highly accurate test can still produce a surprisingly low probability of actually having a rare condition.

How to use it

  1. 1 Enter P(B|A) — the probability of observing B if A is actually true (a test's sensitivity, for a medical example).
  2. 2 Enter P(A) — the prior, baseline probability of A before any new evidence (the condition's base rate in the population).
  3. 3 Enter P(B) — the overall probability of observing B across the entire population, whether or not A is actually true.

Understanding Bayes Theorem Calculator with Examples

Bayes' theorem is the mathematical foundation for correctly updating a belief or probability in light of new evidence, and its most famous, genuinely counterintuitive application — medical test interpretation — reveals exactly why intuition alone routinely gets conditional probability wrong, and why the base rate (how common something is to begin with) matters just as much as a test's own accuracy.

The core confusion Bayes' theorem exists to resolve is mixing up two genuinely different conditional probabilities that sound superficially similar: P(B|A), the probability of evidence B given that hypothesis A is actually true (a test's sensitivity — how likely a genuinely sick person is to test positive), and P(A|B), the probability that hypothesis A is actually true given that evidence B was observed (the real-world question anyone receiving a positive test result actually cares about — given that I tested positive, what's the real probability I'm actually sick). These two probabilities are not the same number, and conflating them — assuming a test's stated accuracy directly answers 'given my positive result, what's my real risk' — is exactly the base rate fallacy, one of the most common and consequential probability misunderstandings in everyday reasoning about risk.

The worked example in this calculator's own defaults illustrates the fallacy concretely: a test that's 90% accurate (meaning P(B|A) = 90%, correctly flagging 90% of people who genuinely have the condition) applied to a condition with only a 1% base rate in the population produces a real positive-predictive probability of just 9% — meaning a randomly selected person receiving a positive result on this test actually has only about a 1-in-11 chance of genuinely having the condition, despite the test's headline 90% accuracy figure sounding much more reassuring (or alarming, depending on framing) than that real 9% number.

The reason this happens becomes clear once you think through the actual population math rather than focusing purely on the test's own accuracy in isolation. Imagine 10,000 people tested: at a 1% base rate, 100 of them genuinely have the condition, and at 90% test sensitivity, about 90 of those 100 correctly test positive (true positives). But among the remaining 9,900 people who don't have the condition, the test's false-positive rate (in this example, implied by the numbers, working out to roughly the remaining share needed to reach the given overall 10% positive rate) still produces a substantial number of false positives — people without the condition who nonetheless test positive. Because the healthy population (9,900) is so much larger than the genuinely sick population (100), even a relatively low false-positive rate applied to that much larger healthy group can produce more total false positives than true positives, which is exactly why a randomly selected positive result is more likely, in this specific numeric example, to be a false positive than a genuine true positive — the rarity of the condition itself, not any flaw in the test's own accuracy, is what drives this surprising result.

This exact pattern — rare conditions producing counterintuitively low real-world positive-predictive values even from genuinely accurate tests — is why base rate is such a critical, and so frequently overlooked, factor in correctly interpreting real-world test results, whether medical, security-screening, fraud-detection, or any other 'test for a rare thing' scenario. Bayes' theorem is exactly the tool for correctly combining a test's own known accuracy with the base rate of what's actually being tested for, producing the genuinely meaningful answer to the question people actually care about (given my result, what's my real probability) rather than the easily-misinterpreted raw test-accuracy figure alone.

Worked examples

Advantages

  • Directly computes the updated, evidence-informed probability, not just the raw test accuracy figure people often mistakenly substitute for it.
  • Makes explicit how much the base rate (P(A)) matters, not just the test's own accuracy.
  • Works for any conditional-probability scenario, not just the classic medical-testing example.
  • Prevents the extremely common 'base rate fallacy' — mistaking a test's raw accuracy for the actual probability of a positive result being correct.

Limitations

  • Requires knowing (or reasonably estimating) all three input probabilities — a result is only as reliable as the accuracy of the P(B|A), P(A) and P(B) values entered.

Common mistakes

  • ⚠️ Confusing P(B|A) with P(A|B) — these are genuinely different quantities (a test's accuracy given a true condition, versus the actual probability of the condition given a positive test), and mixing them up is exactly the base rate fallacy Bayes' theorem exists to correct.
  • ⚠️ Ignoring the base rate P(A) entirely and treating a test's stated accuracy as if it directly answered 'given a positive result, what's the real probability,' when the base rate can dramatically change the actual answer, especially for rare conditions.
  • ⚠️ Not correctly finding P(B) — the overall probability of the evidence occurring across the whole population, not just within the group where A is true, which requires accounting for both true positives and false positives together.

Tips

  • 💡 Why does a 90%-accurate test only give a 9% real probability in the first example? Because the condition itself is rare (1% base rate) — most positive results actually come from the much larger group of people who don't have the condition but still tested positive (false positives), not from the small group who genuinely do.
  • 💡 The rarer the condition (the lower P(A)), the more a positive test result needs to be discounted relative to the test's own raw accuracy — this is exactly why base rate matters so much in real medical testing interpretation.
  • 💡 P(B), the overall probability of the evidence, needs to account for every way B can occur — both when A is true and when A is false — not just the scenario where A happens to be true.
  • 💡 Use this calculator any time you're tempted to treat 'probability of evidence given a hypothesis' and 'probability of a hypothesis given evidence' as if they were the same number — they're very often meaningfully different.

Real-life uses

  • Interpreting a medical test result correctly, accounting for a condition's base rate
  • Evaluating how strongly new evidence should actually shift a prior belief
  • Understanding why a highly accurate test can still produce a surprisingly low real-world probability for a rare condition
  • Spam filtering, fraud detection, and other systems that update a probability based on new observed evidence

Frequently asked questions

Why does a 90%-accurate test only give a 9% real probability in the first example?

Because the condition itself is rare (1% base rate) — most positive results actually come from the much larger group of people who don't have the condition but still tested positive (false positives), not from the small group who genuinely do.

What is the base rate fallacy?

It's the common mistake of treating a test's own accuracy (P(B|A)) as if it directly answers the real question of interest (P(A|B)) — ignoring how common or rare the condition actually is in the first place.

Why does P(B) need to include false positives, not just true positives?

P(B) is the overall probability of the evidence occurring across everyone, whether or not A is true — leaving out false positives would understate the true total probability of observing B.

Does base rate matter more for rare or common conditions?

It matters more for rare conditions — the rarer the condition, the more a positive test result needs to be discounted relative to the test's own raw accuracy figure.

What other applications use Bayes' theorem besides medical testing?

Spam filtering, fraud detection, and any system that needs to update a probability estimate based on newly observed evidence all rely on exactly this same underlying calculation.