Skip to content

Bayes Theorem Calculator

Enter the prior probability, the sensitivity, and the specificity. The calculator applies Bayes' theorem to find the probability that a positive result is a true positive, then shows the negative predictive value and how many positives are false.

Updated 2026-11-18 Editorial estimate Calccc Editorial Team Free · No sign-up
%

How common the condition is before the test, such as its prevalence in the group.

%

Probability of a positive result when the condition is present.

%

Probability of a negative result when the condition is absent.

Scenarios A/BSave two input sets and compare the results. Stored only in this browser.
AEmpty
BEmpty

Your inputs stay in this browser. No account, no uploads.

Professional worksheet

Detailed schedule & assumptions

Inputs used, method, sensitivity, and any year-by-year table. The summary above stays compact; the audit lives here.

Professional worksheet

Inputs, scope, and sensitivity

Inputs used

Method and scope

Result audit

MetricValue

What this calculator does

Bayes' theorem describes how a belief should change when new evidence arrives. In a testing context, the prior is how common the condition is before the test, sensitivity is the chance of a positive result when the condition is present, and specificity is the chance of a negative result when it is absent. The surprising result is that even a highly accurate test can produce mostly false positives when the condition is rare. This calculator makes that arithmetic visible, which is why the base rate matters as much as the test's accuracy. It is a general probability tool for teaching and planning, not a diagnosis or a substitute for clinical judgement.

How to use it

  1. Enter the prior probability as a percentage.
  2. Enter the sensitivity, the true positive rate.
  3. Enter the specificity, the true negative rate.
  4. Read the posterior probability for a positive result.
  5. Check the false-positive share to see how much a positive result depends on the base rate.

How it works

Posterior = sensitivity x prior / (sensitivity x prior + (1 - specificity) x (1 - prior)). Negative predictive value = specificity x (1 - prior) / (specificity x (1 - prior) + (1 - sensitivity) x prior). In the default case, a 1.0% prior with 90% sensitivity and 95% specificity gives a posterior of 15.38%.

Example calculations

Example 1: A 1% prior with a 90/95 test

A positive result raises the probability from 1.0% to 15.38%. Because the condition is rare, 84.6% of positive results are false positives, and the negative predictive value is 99.89%.

Example 2: A 10% prior with a 99/99 test

With a more common condition and a more accurate test, the posterior rises to 91.67%. The same sensitivity and specificity would give a much lower posterior with a 1% prior, which shows how strongly the base rate matters.

Example 3: A 0.1% prior with a coin-flip test

When sensitivity and specificity are both 50%, a positive result barely changes the probability: the posterior is 0.10%. The share of positives that are false reaches 99.9%.

What the result means

The posterior is the probability that a positive result is a true positive, given the prior and the test characteristics. It is not the probability that the person has the condition in every context, because the prior may differ between populations. Sensitivity and specificity are properties of the test, but the posterior depends on the population being tested, which is why screening programmes and repeat testing are designed around prevalence. The calculator also shows the negative predictive value, which is usually high when the condition is rare. Real tests have indeterminate results, imperfect gold standards, and spectrum effects, so the output is an illustration of the arithmetic rather than a clinical answer.

Common mistakes

  • Confusing sensitivity with the probability of having the condition after a positive test.
  • Ignoring the prior and treating the test result as conclusive.
  • Using a prevalence from a different population than the one being tested.
  • Forgetting that a negative result can still be a false negative.
  • Treating the output as a diagnosis rather than a probability.

Assumptions and limits

  • Sensitivity and specificity are constant across the tested population.
  • The prior accurately reflects the prevalence in that population.
  • The test result is binary, with no indeterminate outcomes.
  • The test and the condition are independent of other risk factors beyond the prior.
  • The arithmetic is exact, with no measurement error in the inputs.

Frequently asked questions

What does Bayes' theorem actually calculate?

It calculates the probability of a hypothesis given evidence, using the prior probability and the likelihood of the evidence under each hypothesis. In testing terms, it turns sensitivity and specificity into the probability that a positive result is a true positive.

Why can a positive result still be a false positive?

When the condition is rare, there are many more healthy people than affected people. Even a small false-positive rate applied to a large healthy group can produce more false positives than true positives, so the posterior stays low.

What is the difference between sensitivity and specificity?

Sensitivity is the share of affected people who test positive. Specificity is the share of unaffected people who test negative. A test can be good at one and weaker at the other, and the trade-off depends on the threshold used.

What is the negative predictive value?

The probability that a person with a negative result does not have the condition. It is usually high when the condition is rare, but it falls when sensitivity is low, because more affected people are missed.

Does this apply outside medicine?

Yes. The same arithmetic applies to spam filters, quality control, fraud detection, and any test with a prior and two error rates. The interpretation of the prior changes, but the formula does not.

Can I use this to decide whether to take a test?

It can help you understand what a result would mean, but it is not a decision tool on its own. The consequences of false positives and false negatives, the availability of confirmatory testing, and clinical judgement all matter.

Sources

This calculator is an educational probability tool, not a medical or diagnostic device. Test characteristics vary, and real results require confirmatory testing and professional interpretation.

2026 update

How to use the professional output

This page is not just a formula box. The result is designed to be checked, compared, and taken away.

  • Professional worksheet. The result includes the inputs used, the method and scope, and a one-variable sensitivity check for finance calculators.
  • A/B scenarios. Save two input sets in the browser and compare the primary, secondary, and breakdown figures side by side.
  • Print / PDF and CSV. Print a branded worksheet, or export the year-by-year table when the calculator produces one.

The formulas and assumptions above still govern the number. The worksheet makes the estimate auditable; it does not make it a lender quote, tax return, or personalized advice.

Calccc Editorial Team · Updated 2026-11-18

Prepared by Calccc Editorial Team as an educational estimate. This page is not a licensed professional review and is not financial, medical, legal, or tax advice.

Editorial estimate prepared by the Calccc Editorial Team; not a licensed professional review.