Bayesian Prior Calculator
Apply Bayes' theorem to update a prior probability given test sensitivity and false positive rate. Calculate the posterior probability after a positive or negative result.
About this calculator
This calculator applies Bayes' theorem (line 8: P(A|B) = P(B|A)P(A) / [P(B|A)P(A) + P(B|¬A)P(¬A)]) to update a Prior Probability P(A) after a positive or negative test result, using Sensitivity as the true-positive rate and False Positive Rate as the false-alarm rate. All three inputs pass through Math.min(Math.max(inputs.X || default, 0.0001), 0.9999) (lines 4-6) before any arithmetic runs — but the || runs first, so 0 and 1 aren't treated the same way. Typing exactly 1 is truthy, so it reaches the clamp untouched and gets pulled down to 0.9999. Typing exactly 0 (or clearing the field) is falsy, so it's replaced by that field's own default — 0.01 for Prior Probability, 0.9 for Sensitivity, 0.05 for False Positive Rate — before the clamp ever runs, so it isn't clamped to a boundary at all.
Positive Likelihood Ratio and Negative Likelihood Ratio (lines 25-26) are pure ratios of Sensitivity and False Positive Rate — Prior Probability plays no role in either formula at all, a fact readable directly from the code rather than inferred from a sweep. Prior Odds (line 29) is likewise computed purely from Prior Probability and stays completely fixed however Sensitivity or False Positive Rate change. Posterior P(A | negative test) responds far more strongly to Sensitivity than to Prior Probability, since a highly sensitive test is defined by how rarely it produces a false negative — exactly what a negative result needs to rule out. This calculator does not account for sequential testing: running the same test twice, or combining two different tests, requires manually feeding the first posterior back in as the new prior, since there's no built-in mechanism here for chaining test results.
Inputs
Results
Posterior P(A | positive test)
0.16
Posterior P(A | negative test)
0
How to Use This Calculator
- Enter the Prior Probability — your belief that the condition is present before seeing the test result (e.g., disease prevalence).
- Enter the Sensitivity (true positive rate) — the probability the test is positive given the condition is present.
- Enter the False Positive Rate — the probability the test is positive when the condition is absent (1 − Specificity).
- Bayes' theorem updates the prior: P(condition | positive test) = (sensitivity × prior) / P(positive test).
- The Posterior Probability is the updated belief after a positive result; it depends heavily on the prior.
- Low prevalence dramatically reduces the positive predictive value even for highly sensitive tests — this is the base rate fallacy.
How the result changes with Prior Probability P(A)
| Prior Probability P(A) | Posterior P(A | positive test) | Posterior P(A | negative test) |
|---|---|---|
| 0.01 | 0.09 | 0 |
| 0.01 | 0.13 | 0 |
| 0.02 | 0.22 | 0 |
| 0.03 | 0.33 | 0 |
What each input means
- Prior Probability P(A)
- Your initial belief about the probability before seeing evidence. E.g., disease prevalence.
- Sensitivity (True Positive Rate)
- Probability of a positive test given the condition is present. Also called recall or TPR.
- False Positive Rate
- Probability of a positive test given the condition is absent. Equal to 1 - specificity.
How this is calculated
Worked example, using the default values
- Identify Input ParametersPrior Probability P(A) = 0.01, Sensitivity (True Positive Rate) = 0.95, False Positive Rate = 0.05 = 3 input(s) provided
- Calculate Posterior PPosterior P0.161 = 0.161
- Calculate Posterior PPosterior P0.0005 = 0.0005
- Calculate Positive Likelihood RatioPositive Likelihood Ratio = Math19 = 19
- Calculate Negative Likelihood RatioNegative Likelihood Ratio0.0526 = 0.0526
Engine last updated . Checked against 2 independently-derived tests — how we verify calculators. Built by Paul Gunder, a software engineer, not a licensed financial, medical, or legal professional.
Frequently Asked Questions
Does the Prior Probability affect the Positive Likelihood Ratio?
No. Positive Likelihood Ratio is computed purely as Sensitivity divided by False Positive Rate (line 25) and never reads Prior Probability at all — the two likelihood ratios describe the test itself, independent of how common the condition is in the population you're testing.
Why does Prior Odds ignore Sensitivity and False Positive Rate?
Prior Odds is calculated purely from Prior Probability as priorProbability / (1 - priorProbability) (line 29) before any test result is factored in — it's a restatement of your starting belief in odds form, and the test's accuracy characteristics simply haven't entered the calculation at that point yet.
What happens if I type 0 or 100% into one of the probability fields?
It depends which boundary. All three fields use Math.min(Math.max(inputs.X || default, 0.0001), 0.9999) (lines 4-6), and the || runs before the clamp. Typing exactly 1 is truthy, so it passes through and gets clamped down to 0.9999 as you'd expect. Typing exactly 0 — or clearing the field — is falsy, so it's replaced by that field's own default (0.01 for Prior Probability, 0.9 for Sensitivity, 0.05 for False Positive Rate) before the clamp ever runs; it isn't clamped to a boundary at all, it just silently reverts to the default.
Which input moves Posterior P(A | negative test) the most?
Sensitivity has by far the largest effect on it. A given change to Sensitivity shifts the negative-test posterior far more than an equivalent change to Prior Probability, because a highly sensitive test is defined by how rarely it produces a false negative, which directly controls how much a negative result should reassure you.
Related Calculators
The questions that sit next to this one — chosen by subject, including calculators filed under a different category.
ROC Curve Calculator
Calculate sensitivity, specificity, PPV, NPV, accuracy, F1 score, and approximate AUC from a confusion matrix (TP, FP, TN, FN).
StatisticsFisher's Exact Test Calculator
Perform Fisher's exact test on a 2x2 contingency table to determine if there is a significant association between two categorical variables.
Machine Learning & AIBayesian Inference Calculator
Calculate posterior probability, Bayes factor, likelihood ratio, and evidence strength using Bayes' theorem.
Forensic ScienceDNA Match Probability Calculator
Calculate random match probability and likelihood ratio for DNA evidence based on loci matched, population size, and allele frequencies.
StatisticsZ-Score Calculator
Calculate the z-score (standard score) for any value in a normal distribution. Find the percentile ranking and probability associated with your data point.
More in Math & Statistics.