DevTools Logo

Bayes Theorem Calculator

Bayes Theorem Calculator

Update probabilities with new evidence

Runs in your browser

Test characteristics

Percentages · live result
Try an example

How common the condition is before testing.

Chance the test is positive when the condition is present.

Observed result

Posterior probability

P(A|B)

P(A | B)

16.67%

A positive result raises the chance of the condition from 1.00% to 16.67%.

About 1 in 6 positive results is a true condition.

P(no A | evidence)
83.33%
P(result) — total
5.94%
PPV P(A | positive)
16.67%
NPV P(no A | negative)
99.99%
Lift vs prior
16.67×
LR +
19.80

Worked steps

  1. Prior

    P(A) = 0.0100; P(¬A) = 1 − 0.0100 = 0.9900

  2. Test likelihoods

    P(B|A) = 0.9900; P(B|¬A) = 0.0500

  3. Total probability of the result

    P(B) = 0.9900 × 0.0100 + 0.0500 × 0.9900 = 0.0594

  4. Bayes' theorem

    P(A|B) = (0.9900 × 0.0100) / 0.0594 = 0.1667

  5. Odds form (optional)

    odds(A|B) = [0.0100 / 0.9900] × 19.8000 = 0.2000

Natural frequencies per 1,000 people

  • True positive: 10
  • False negative: 0
  • False positive: 50
  • True negative: 940

Exact joint counts are rounded to whole people; cells always add up to 1,000.

Confusion matrix of condition against test result
Test positiveTest negativeTotal
Condition present10010
Condition absent50940990

Posterior vs prior

0%50%100%
Show sweep data table
PriorPosterior
0.010%0.20%
0.049%0.96%
0.239%4.54%
1.172%19.02%
5.736%54.64%
28.070%88.54%

Educational tool only — not medical advice. Your inputs stay in this browser tab and are never stored or sent anywhere.

Examples

Mammography classic

Prior 1%, sensitivity 99%, specificity 95% gives a posterior of only 16.67% after a positive result — about 10 true positives versus 50 false positives per 1,000 people.

Negative result

Switch the observed result to negative with the same screening test to see P(A|¬B) ≈ 0.0106% and the NPV of 99.9894%.

Base-rate neglect

Set specificity to 5% (equal to a 95% sensitivity): the test is uninformative, the likelihood ratio is 1 and the posterior equals the prior — whatever the prior is.

About this tool

Bayes' theorem answers a deceptively simple question: after a positive test, how likely is the condition really? Enter a prior prevalence, a test sensitivity P(positive|A) and either specificity P(negative|¬A) or the false-positive rate, and the tool computes the posterior P(A|B) = P(B|A) × P(A) / P(B), where P(B) = P(B|A) × P(A) + P(B|¬A) × P(¬A). Choose a negative result to get P(A|¬B) with the same formula. The worked steps substitute your numbers into each line, so you can check homework or teach the base-rate fallacy. A natural-frequency grid per 1,000 people makes the false-positive paradox visible: with a 1% prior, 99% sensitivity and 95% specificity, only about 10 of 60 positive results are true positives — a posterior of 16.67%, not 99%. The confusion matrix, PPV/NPV, likelihood ratios and a posterior-versus-prior curve are all computed from the same inputs. You can repeat an independent test up to five times and watch the posterior update step by step. Everything runs in this browser tab: nothing is stored or transmitted. Educational tool only — not medical advice; consult a qualified professional for health decisions.

What this tool does not do

  • Processes only the inputs provided in this session without connecting to external accounts or background servers.
  • Runs entirely in the current browser tab; nothing is synced across devices or backed up to a server.

How to use this tool

  1. Enter prior, sensitivity, and specificity

    Set base-rate prevalence and test accuracy (or false-positive rate).

  2. Select observed result

    Choose a positive or negative test outcome and optional repeat-test count.

  3. Read posterior and 1,000-person grid

    Inspect P(A|B), worked formula steps, PPV/NPV, and the natural-frequency matrix.

Use cases

Mammography classic

Prior 1%, sensitivity 99%, specificity 95% gives a posterior of only 16.67% after a positive result — about 10 true positives versus 50 false positives per 1,000 people.

Negative result

Switch the observed result to negative with the same screening test to see P(A|¬B) ≈ 0.0106% and the NPV of 99.9894%.

Base-rate neglect

Set specificity to 5% (equal to a 95% sensitivity): the test is uninformative, the likelihood ratio is 1 and the posterior equals the prior — whatever the prior is.

Common mistakes

Mistake:What is the difference between sensitivity and positive predictive value (PPV)?

Fix:Sensitivity P(+|A) measures how often the test detects the condition when present, whereas PPV P(A|+) is the posterior probability that you actually have the condition given a positive result.

Mistake:How does sequential test updating work?

Fix:When two tests are conditionally independent, the posterior probability from the first test becomes the prior probability for the second test, sharpening confidence step by step.

Frequently asked questions

Why can a positive test still have a low probability for rare conditions?

When base-rate prevalence is very low (for example 1%), even a 5% false-positive rate across the 99% unaffected population produces more false positives than true positives. The 1,000-person natural-frequency grid makes this ratio concrete.

What is the difference between sensitivity and positive predictive value (PPV)?

Sensitivity P(+|A) measures how often the test detects the condition when present, whereas PPV P(A|+) is the posterior probability that you actually have the condition given a positive result.

How does sequential test updating work?

When two tests are conditionally independent, the posterior probability from the first test becomes the prior probability for the second test, sharpening confidence step by step.

Can I use this calculator for medical diagnosis?

No. This is an educational probability tool; real clinical tests involve correlated results, spectrum bias, and patient history that require a qualified healthcare professional.