Skip to content
The Calculatorz
Probability

Bayes’ Theorem Calculator (Diagnostic Test Probability)

Use Bayes' theorem to find the probability of a condition after a positive or negative test, from prevalence, sensitivity and specificity.

Statistical results depend on the assumptions stated in the formula. Check that your data meet them before drawing conclusions.

Prior and test accuracy

Test

How to use this calculator

Enter how common the condition is before testing (the prior probability), the test's sensitivity and its specificity. The calculator applies Bayes' theorem to give the chance that a positive result is a true positive (positive predictive value) and that a negative result is a true negative, and shows the results per 10,000 people tested.

Formula

P(A | +) = P(+ | A) × P(A) ÷ [P(+ | A) × P(A) + P(+ | not A) × P(not A)], where P(+ | A) is sensitivity and P(+ | not A) = 1 − specificity. Negative predictive value = specificity × (1 − prevalence) ÷ [specificity × (1 − prevalence) + (1 − sensitivity) × prevalence].

Calculator credits

Calculator developmentJulia Edwards

Editorial supervision

Expert reviewSaeedM.Phil Statistics, Data Scientist

Published byThe Calculatorz

Last updated

Read how we research, test, review and correct our calculators in our editorial policy.

Frequently asked questions

What is Bayes' theorem?

A rule for updating a probability with new evidence: the probability of A given B equals the probability of B given A, times the prior probability of A, divided by the overall probability of B.

Why is a positive test often wrong for rare conditions?

When a condition is rare, false positives from the large healthy group can outnumber true positives, even with an accurate test.

What are sensitivity and specificity?

Sensitivity is the share of people with the condition who test positive; specificity is the share without it who test negative.

What is the base rate fallacy?

Ignoring the prior probability and assuming a positive result from a 95% accurate test means a 95% chance of having the condition.

Can I use it outside medicine?

Yes, for spam filters, fraud alerts, quality checks or any situation where evidence updates a prior belief.

How can predictive value be improved?

Testing people with a higher prior probability (for example those with symptoms) or confirming positives with a second, independent test.

References & methodology sources

These sources support the calculator’s formula, definitions, thresholds, units or result interpretation.

  1. Ross, S. M. (2019). A first course in probability (10th ed.). Pearson. View source
  2. Illowsky, B., & Dean, S. (2023). Introductory statistics 2e. OpenStax. View source
  3. Croarkin, C., & Tobias, P. (Eds.). (2012). NIST/SEMATECH e-handbook of statistical methods. National Institute of Standards and Technology. View source
  4. Casella, G., & Berger, R. L. (2002). Statistical inference (2nd ed.). Duxbury. View source