Bayes' Theorem Calculator
Posterior probability P(A|B) from a prior and likelihoods, or a test's positive and negative predictive value.
P(A|B) = P(B|A)·P(A) ÷ [P(B|A)·P(A) + P(B|¬A)·(1 − P(A))]. A test with 90% sensitivity and 95% specificity for a condition with 1% prevalence: 0.009 ÷ (0.009 + 0.0495) = 15.4%, so most positives are false.
Free, runs in your browser. Nothing you enter is uploaded.
How to use it
- Choose a general problem or a diagnostic test.
- Enter the prior (or prevalence) and the two conditional probabilities (or sensitivity and specificity).
- Read the posterior probability and the plain-language breakdown.
What you enter
- Prior P(A) or prevalence
- P(B|A) or sensitivity
- P(B|¬A) or 1 − specificity
What you get
- Posterior P(A|B)
- P(B)
- Positive and negative predictive value
Formula
P(A|B) = P(B|A) P(A) / P(B) | P(B) = P(B|A) P(A) + P(B|¬A) P(¬A)
Worked example: screening test
Input: Prevalence 1%, sensitivity 90%, specificity 95%
Result: PPV 15.4%, NPV 99.9%
A positive result needs a confirmatory test; a negative result is very reassuring.
Questions
What is Bayes' theorem in simple terms?
It updates how likely something is once you see new evidence, weighing how well that evidence fits each possibility against how common each possibility was to begin with.
Why is a positive test often wrong for a rare disease?
When prevalence is low, the few true positives are outnumbered by false positives from the much larger healthy group. This is the base rate fallacy.
What is the difference between P(A|B) and P(B|A)?
P(B|A) is how often the evidence appears when A is true (like sensitivity). P(A|B) is how likely A is once you have seen the evidence. Bayes' theorem converts one into the other.
How do I use Bayes' theorem with more than two hypotheses?
Divide each prior × likelihood by the sum of prior × likelihood across all hypotheses. The two-hypothesis form here is the common special case.
References
Related reading
- Bayes' Theorem: Definition, Formula and Examples
- Bayes' Theorem in Biology: Worked Examples
- Bayesian Reasoning in Veterinary Diagnosis
- Bayesian Methods for Diagnostic Test Evaluation in Animals
More Statistics
- Standard Deviation Calculator
- Mean, Median & Mode Calculator
- Variance Calculator
- Z-Score Calculator
- P-Value Calculator
- Confidence Interval Calculator
- T-Test Calculator
- Chi-Square Test Calculator
- Correlation Coefficient Calculator
- Linear Regression Calculator
- Normal Distribution Calculator
- Probability Calculator
All free tools · By Dr. Zubair Khalid, DVM, MS, PhD.