Bayes' Theorem Calculator

Posterior probability P(A|B)16.67%
Overall probability of the evidence P(B)5.94%
Prior probability P(A)1.00%
How this was calculated
  1. Weight the evidence by both ways it can occur: P(B) = 99% × 1% + 5% × 99% = 5.94%.
  2. Bayes' theorem then takes the true-positive share of that evidence: P(A|B) = 0.99 ÷ 5.94 = 16.67%.
  3. Notice the base-rate effect: with a rare condition, even a test that is right 99% of the time leaves most positives false, because the false positives are drawn from a far larger pool of healthy cases.

This Bayes theorem calculator gives you the posterior probability P(A|B) using Bayes' theorem: P(A|B) = P(B|A) x P(A) / P(B), where P(B) = P(B|A) x P(A) + P(B|not A) x P(not A). Enter the prior probability, sensitivity, and false-positive rate, and the calculator returns the updated probability. For example, a prior of 1%, sensitivity of 99%, and false-positive rate of 5% gives P(B) = 0.99 x 0.01 + 0.05 x 0.99 = 5.94% and a posterior of 0.99 / 5.94 = 16.67%. With a prior of 10%, sensitivity of 95%, and false-positive rate of 10%, the posterior is 51.35%. With a prior of 50%, sensitivity of 90%, and false-positive rate of 10%, the posterior is 90.00%.

Bayes' theorem, named for Thomas Bayes, whose essay was published posthumously in 1763, with Laplace later developing the modern form, is the accepted standard for updating probabilities with new evidence. It accounts for the base-rate effect: when the prior is small, false positives drawn from the large healthy population can outnumber true positives even with an accurate test, which is why screening low-risk populations produces mostly false alarms. In odds form, posterior odds = prior odds x likelihood ratio, which is how clinicians chain several test results together. This page shows the formula, step-by-step workings, worked examples, and sources.

Worked examples

The screening paradox

Primary result: 16.67% — a test that catches 99% of cases of a 1%-prevalence condition still leaves five of six positives false. (1 % · 99 % · 5 %)

Posterior probability P(A|B)16.67%
Overall probability of the evidence P(B)5.94%
Prior probability P(A)1.00%

A common condition

Primary result: 51.35% — with a 10% prior and a 95%/10% test, a positive lands almost exactly at coin-flip. (10 % · 95 % · 10 %)

Posterior probability P(A|B)51.35%
Overall probability of the evidence P(B)18.50%
Prior probability P(A)10.00%

Starting from 50/50

Primary result: 90.00% — from an even prior, a 90%/10% test moves the answer to 90%. (50 % · 90 % · 10 %)

Posterior probability P(A|B)90.00%
Overall probability of the evidence P(B)50.00%
Prior probability P(A)50.00%

The theorem

Bayes' theorem is stated as P(A|B) = P(B|A) x P(A) / P(B). In the language of testing, P(A) is the prior: the probability of having the condition before seeing any test result. P(B|A) is the sensitivity: the probability of testing positive given that the condition is present. P(B|not A) is the false-positive rate: the probability of testing positive given that the condition is absent. P(A|B) is the posterior: the updated probability of having the condition after a positive test result.

The denominator P(B) is the total probability of a positive test result, combining both routes to the evidence. The first route is a true positive: the patient has the condition and the test correctly detects it, giving P(B|A) x P(A). The second route is a false positive: the patient does not have the condition but the test returns positive anyway, giving P(B|not A) x P(not A). Adding these together yields P(B) = P(B|A) x P(A) + P(B|not A) x P(not A).

A worked example shows why this matters. With a prior of 1%, a sensitivity of 99%, and a false-positive rate of 5%, P(B) = 0.99 x 0.01 + 0.05 x 0.99 = 5.94%. The posterior is then 0.99 / 5.94 = 16.67%. A test that seems highly accurate still leaves most positive results as false alarms, because the small prior means false positives drawn from the large healthy population can outnumber true positives. This is the base-rate effect, and it is the reason screening low-risk populations produces mostly false alarms. Raising the prior to 10% with a sensitivity of 95% and a false-positive rate of 10% gives a posterior of 51.35%. At a prior of 50%, a sensitivity of 90%, and a false-positive rate of 10%, the posterior reaches 90.00%.

In odds form, Bayes' theorem says posterior odds = prior odds x likelihood ratio. This is how clinicians chain several test results together, updating the odds with each new piece of evidence. The theorem is named for Thomas Bayes, whose essay was published posthumously in 1763; Laplace later developed the modern form. A bayes theorem calculator applies this formula directly, letting users enter the prior, sensitivity, and false-positive rate to obtain the posterior without working through the arithmetic by hand.

The worked examples

To see exactly how a Bayes theorem calculator handles real inputs, walk through three scenarios that share the same structure. In each one, P(B) is computed first using P(B) = P(B|A) x P(A) + P(B|not A) x P(not A), then the posterior follows from P(A|B) = P(B|A) x P(A) / P(B).

First, take a rare condition with a prior of 1%, a test sensitivity of 99%, and a false-positive rate of 5%. The denominator P(B) = 0.99 x 0.01 + 0.05 x 0.99 = 0.0099 + 0.0495 = 0.0594, or 5.94%. The posterior is 0.99 x 0.01 / 0.0594 = 0.0099 / 0.0594 = 16.67%. Despite a test that catches 99% of true cases, fewer than 1 in 6 positive results points to a real case. This is the base-rate effect at work: when the prior is small, false positives drawn from the large healthy population can outnumber true positives even with an accurate test — the reason screening low-risk populations produces mostly false alarms.

Second, raise the prior to 10% while keeping a strong but imperfect test: sensitivity 95%, false-positive rate 10%. Now P(B) = 0.95 x 0.10 + 0.10 x 0.90 = 0.095 + 0.090 = 0.185, or 18.50%. The posterior becomes 0.95 x 0.10 / 0.185 = 0.095 / 0.185 = 51.35%. A positive result now tilts the odds above 50-50, but the false-positive rate still drags the number down well below the raw sensitivity.

Third, set the prior to 50% with sensitivity 90% and false-positive rate 10%. Here P(B) = 0.90 x 0.50 + 0.10 x 0.50 = 0.45 + 0.05 = 0.50, or 50.00%. The posterior is 0.90 x 0.50 / 0.50 = 0.45 / 0.50 = 90.00%. With prior and denominator equal, the posterior simply equals the likelihood ratio 0.90 / 0.10 = 9 expressed as a probability, giving a clean 90.00%.

These three examples share one lesson: the posterior depends as much on who is being tested as on how good the test is. In odds form, Bayes' theorem says posterior odds = prior odds x likelihood ratio, which is how clinicians chain several test results together. The theorem is named for Thomas Bayes, whose essay was published posthumously in 1763; Laplace later developed the modern form. Running the same numbers through a Bayes theorem calculator reproduces each step above and makes the base-rate effect easy to spot.

The base-rate effect

The base-rate effect is the counterintuitive reason a bayes theorem calculator can return a surprisingly low posterior even when a test sounds highly reliable. When the prior is small, false positives drawn from the large healthy population can outnumber true positives even with an accurate test. This is why screening low-risk populations produces mostly false alarms.

To make this visceral, picture 1,000 people in a screening program where the condition has a prior of 1%. Only 10 people actually have the condition. A test with 99% sensitivity will correctly flag about 10 of them. But the remaining 990 healthy people are each subject to a 5% false-positive rate, producing roughly 50 false alarms. The total positive results are 60, but only about 10 are true positives. Using Bayes' theorem, P(B) = 0.99 x 0.01 + 0.05 x 0.99 = 5.94%, and the posterior is 0.99 / 5.94 = 16.67%. So even with a 99% sensitive test, fewer than 1 in 5 positive results are real.

The prior matters so much that raising it from 1% to 10% dramatically shifts the outcome. With a 10% prior, 95% sensitivity, and a 10% false-positive rate, the posterior jumps to 51.35%. Push the prior to 50% with 90% sensitivity and a 10% false-positive rate, and the posterior reaches 90.00%. The same test performs radically differently depending on who you test.

In odds form, Bayes' theorem says posterior odds = prior odds x likelihood ratio, which is how clinicians chain several test results together. A second independent test multiplies the likelihood ratio again, pulling the posterior up or down with each result. This framework, named for Thomas Bayes whose essay was published posthumously in 1763 and later developed into its modern form by Laplace, turns a single confusing screening result into a sequence of evidence that converges on the truth.

The odds form and chaining evidence

The standard form of Bayes' theorem, P(A|B) = P(B|A) x P(A) / P(B), where P(B) = P(B|A) x P(A) + P(B|not A) x P(not A), works well for a single piece of evidence. But clinicians often need to combine several test results, and multiplying probabilities directly becomes unwieldy. The odds form of the theorem simplifies this: posterior odds = prior odds x likelihood ratio. Odds here simply mean the ratio of the probability that a condition is present to the probability that it is not. The likelihood ratio captures how much a test result shifts those odds, comparing the probability of that result if the condition is present to the probability of that result if it is absent.

This form is powerful because it lets you chain evidence. Once you update the odds after the first test, those posterior odds become the prior odds for the next test. You multiply by a new likelihood ratio, and the cycle repeats. A bayes theorem calculator that handles odds form lets you stack results without resetting to the original prior each time, which mirrors how doctors actually reason through a sequence of findings.

The base-rate effect explains why the starting point matters so much. When the prior is small, false positives drawn from the large healthy population can outnumber true positives even with an accurate test, which is the reason screening low-risk populations produces mostly false alarms. The worked examples make this vivid. A prior of 1%, sensitivity of 99%, and false-positive rate of 5% gives P(B) = 0.99 x 0.01 + 0.05 x 0.99 = 5.94%, and a posterior of 0.99 / 5.94 = 16.67%. Raise the prior to 10% with 95% sensitivity and a 10% false-positive rate, and the posterior jumps to 51.35%. At a 50% prior with 90% sensitivity and a 10% false-positive rate, the posterior reaches 90.00%.

The theorem is named for Thomas Bayes, whose essay was published posthumously in 1763; Laplace later developed the modern form. The odds formulation is part of that later development, and it remains the most practical way to see how evidence accumulates and why a single strong test on a low-risk patient can still leave real uncertainty.

FAQs

What is Bayes' theorem?

Bayes' theorem is a rule for updating a probability when evidence arrives. The formula is: posterior = likelihood x prior / total probability of the evidence. It lets you revise your belief in a hypothesis after seeing new data, making it essential for sound decisions under uncertainty.

Why does a 99% accurate test give only 16.67% here?

Because the condition is rare, with a 1% prior. The 5% false-positive rate acts on 99 healthy people for every 1 true case. So false positives outnumber true positives, and the posterior probability that a positive result means the condition is real drops to 16.67%.

What is a prior probability?

A prior probability is what you believed before this evidence arrived. It may come from prevalence, a base rate, or a previous posterior from earlier updating. The prior anchors the calculation, and Bayes' theorem adjusts it in light of new data to produce the posterior probability.

What is the likelihood ratio form?

The likelihood ratio form states: posterior odds = prior odds x likelihood ratio. This version is handy for chaining multiple pieces of evidence, because each new item multiplies the odds by its own likelihood ratio, letting you update beliefs step by step.

Where is Bayes' theorem used?

Bayes' theorem is used in medical testing, spam filters, forensic reasoning, A/B testing and any sequential updating under uncertainty. Wherever new evidence should change your degree of belief, Bayes provides the framework for combining prior knowledge with observed data.

Who was Bayes?

Thomas Bayes was an 18th-century minister and mathematician. His essay appeared in 1763, after his death, when a friend submitted it for publication. His work established the mathematical foundation for updating probabilities based on evidence, now central to statistics and decision theory.

Sources

Related calculators

Expected Value Calculator
The expected value of a gamble, game or decision from up to four outcomes and their probabilities — with variance and standard deviation for the spread.
Z-Score Calculator
The z-score of any value in a normal distribution, its percentile, and the share of values above and below it — the standardisation behind test scores and quality control.
Confidence Interval Calculator
The range around a sample mean or a sample proportion at 90%, 95% or 99% confidence, with the standard error and margin of error shown step by step.
Sample Size Calculator (Surveys & Proportions)
How many responses a survey or A/B readout needs for a target margin of error — with the finite population correction when the audience is small.