By Waqar Ghouri, founder of CalcMega
This Bayes theorem calculator turns a prior probability, a sensitivity and a specificity into the number people want after a positive test result, the positive predictive value, and most tools that attempt it stop one step early: they never show that a 99 percent accurate looking test, used where the condition affects 1 percent of people, returns a positive result that is right only about 1 time in 6.
That gap between a test that sounds accurate and a result that is usually wrong follows from three honest numbers meeting: a rare condition, a good test, and a very large healthy majority whose occasional false alarms outnumber the true cases. This page shows the whole mechanism, as a formula, as a tree of counts, and as plain frequencies out of 100,000 people, because the frequency version is the one human brains handle well.
Bayes theorem in short
Bayes theorem is the rule for updating a probability when new evidence arrives: the posterior probability equals the likelihood of the evidence times the prior probability, divided by the total probability of the evidence.
On this page's default case, a test with 99 percent sensitivity and 95 percent specificity, used where the condition affects 1 percent of people, gives a positive predictive value of 16.67 percent. Only about 1 in 6 positive results is a real case.
The same test at other prevalences:
| Prevalence | Chance a positive result is real (PPV) | False alarms in every 100 positives |
|---|---|---|
| 0.1% | 1.94% | 98.06 |
| 1% | 16.67% | 83.33 |
| 5% | 51.03% | 48.97 |
| 10% | 68.75% | 31.25 |
| 50% | 95.19% | 4.81 |
Same test figures throughout: 99 percent sensitivity, 95 percent specificity. Each figure is the calculator's exact result at that prevalence.
The top result for "bayes theorem calculator", r-statistics, reads a blank prevalence as 0 percent and prints a PPV of 0 percent. This page asks for a prevalence between 0 and 100 instead, and refuses to compute from a blank field.
How Bayes theorem works: total probability, odds and likelihood ratios
Bayes' theorem, in the diagnostic form, says: PPV equals sensitivity times prevalence, divided by (sensitivity times prevalence plus (1 minus specificity) times (1 minus prevalence)). With the default figures on this page that is (0.99 x 0.01) divided by (0.99 x 0.01 + 0.05 x 0.99), which is 0.0099 divided by 0.0594, which is 0.1667: a PPV of 16.67 percent.
The tree says the same thing in people instead of rates. Out of 100,000 people at 1 percent prevalence, 1,000 have the condition and 99,000 do not. A test with 99 percent sensitivity finds 990 of the 1,000 and misses 10. A test with 95 percent specificity clears 94,050 of the healthy and wrongly flags 4,950. Now count the positive results: 990 true plus 4,950 false makes 5,940 positives, and only 990 of the 5,940 are real. 990 divided by 5,940 is the same 16.67 percent the formula gave. If the two ever disagreed, one of them would be wrong; they are one calculation wearing two coats, and this page prints both so you can cross-check.
There is also an odds form worth knowing, because it powers sequential updating: posterior odds equal prior odds times the likelihood ratio. The positive likelihood ratio, LR+, is sensitivity divided by the false positive rate, here 0.99 divided by 0.05, which is 19.8. A positive result multiplies your odds by about twenty. Starting from 1 percent, prior odds of roughly 1 to 99, one multiplication gives odds of about 1 to 5, which is the same 16.67 percent again.
Three ways in: general, diagnostic and odds form
Sensitivity and specificity sound like twins and are not. Sensitivity is a property measured on people who have the condition: of every 100 true cases, how many does the test catch? Specificity is measured on people who do not: of every 100 healthy people, how many does the test correctly clear? The false positive rate is simply 1 minus specificity, the share of healthy people the test wrongly flags. None of the three knows anything about how common the condition is, and that is precisely why none of them, alone, can tell you what your positive result means.
The trap is reading the pair as a single accuracy score. A test with 99 percent sensitivity and 95 percent specificity is genuinely good, and in a population where the condition is common it performs beautifully. The problem is never the test. The problem is arithmetic: when healthy people outnumber cases ninety-nine to one, a 5 percent error rate applied to the ninety-nine produces more false positives than a 99 percent catch rate applied to the one produces true positives. Prevalence is the third number, and it is the one that decides which of the two error streams wins.
The false positive paradox, counted out in people
The false positive paradox is this collision, named: a test can be highly accurate in both directions and still produce mostly wrong positive results, whenever the condition is rare enough. Here the ratio is stark: 4,950 false positives against 990 true positives means 5 of every 6 positive results, 83.33 percent, are false alarms, even though the test misses only 1 case in 100 and clears 95 healthy people in 100. Screening programmes live inside this paradox permanently, which is why a first positive in screening is an invitation to a second, different test, never a diagnosis.
The mirror statistic completes the picture: the negative predictive value here is 99.99 percent, because a negative result competes against only 10 missed cases among 94,060 negative results. The same test, in the same population, is near certain when it says no and usually wrong when it says yes. Anyone who quotes a single accuracy figure for a test is hiding this asymmetry, and the asymmetry is the whole story.
PPV, NPV and the two error rates
A person holding a result asks one of two questions. After a positive: given that the test says yes, how likely is it that the condition is really there? That is the positive predictive value, PPV, true positives divided by all positives. After a negative: given that the test says no, how likely is it that the condition is really absent? That is the negative predictive value, NPV, true negatives divided by all negatives. Their shadows matter too: the false discovery rate, the share of positives that are false, is 1 minus PPV, and the false omission rate is 1 minus NPV.
One word is banned on this page, deliberately: accuracy. Accuracy blends all four counts into one reassuring figure, 95.04 percent correct calls for the default test and population here, and in doing so it conceals the only thing the person holding the envelope wants to know. PPV is not accuracy, NPV is not accuracy, and calling either of them accuracy is how good tests acquire bad reputations and bad results acquire false confidence.
Worked example: a 99 percent test that is wrong five times in six
Take the default case and count it out in people. Out of 100,000 people at 1 percent prevalence, 1,000 have the condition and 99,000 do not.
Step 1, split the population: 1 percent of 100,000 is 1,000 people with the condition; 99,000 without it.
Step 2, the cases: 99 percent sensitivity finds 990 of the 1,000 and misses 10.
Step 3, the healthy: a 5 percent false positive rate flags 4,950 of the 99,000, and 95 percent specificity clears the other 94,050.
Step 4, divide: 990 true positives out of 990 plus 4,950 positives is 990 divided by 5,940, which is 16.67 percent. The negative side checks the same way: 94,050 true negatives out of 94,060 negative results is 99.99 percent.
Apply the evidence twice: sequential updating
Bayes' theorem is built to be used twice. The posterior from the first result becomes the prior for the second, and in odds form the update is a single multiplication by the second test's likelihood ratio. Apply a second, independent test with the same accuracy to someone whose first result was positive: the odds of 1 to 5 left by the first test are multiplied by LR+ 19.8 again, giving odds of about 4 to 1 in favour, a probability of 79.84 percent. Two positives from a good test, even at 1 percent prevalence, really do mean something.
The condition is independence, and it deserves its own warning because it is the assumption most likely to be false in real life. Two tests that look at the same blood sample, the same image or the same underlying biology tend to fail on the same people: the case the first test misses for a structural reason is often the case the second test misses too. When the blind spots overlap, the second update is smaller than the formula promises, and 79.84 percent is the ceiling, not the estimate. Use sequential updating to understand why confirmatory testing works, and let clinicians who know the specific tests judge how independent theirs really are.
More than two explanations: the multi-hypothesis mode
Sometimes the evidence points at more than two explanations. The multi hypothesis mode splits the prior across as many causes as you list and reweights each by how well it explains the evidence. With priors of 50, 30 and 20 percent and likelihoods of 90, 40 and 10 percent, the total probability of the evidence is 45 plus 12 plus 2, which is 59 percent, and the posteriors come out at 76.27, 20.34 and 3.39 percent: the front runner absorbed most of the second hypothesis's share, because the evidence fitted it more than twice as well.
Solving backwards answers the planning question: how common would the condition need to be for a positive result to be right half the time? For a test with 99 percent sensitivity and 95 percent specificity, a PPV of 50 percent needs a prevalence of about 4.81 percent. Below that line, most positives are false no matter how carefully the test is run; above it, the balance tips. It is the fastest way to see why the same test is a reasonable clinic tool and a questionable mass screening tool, and it is a one line calculation once you know the formula is reversible.
Bayesian updating beyond medicine: spam, courts and everyday evidence
Nothing in the formula mentions medicine. A spam filter is the same machine: a base rate of spam in your inbox, words weighed by how much more often they appear in spam than in real mail, and odds updated word by word. A courtroom runs on it too, and suffers its classic failure when a one in a million match statistic is read as a one in a million chance of innocence, swapping P(evidence given innocence) for P(innocence given evidence), which ignores the base rate of how many people could have produced the match. Even everyday judgement is Bayesian or broken: a friend who is late once is traffic; a friend who is late for the fifth time running has updated your prior, and you plan around the new one.
The failure mode has a name worth keeping: base rate neglect, the habit of judging by the strength of the evidence in front of you while forgetting how common the explanation was before the evidence arrived. Every worked example on this page is the same lesson in different clothes. Strong evidence about a rare thing often still leaves the rare thing unlikely, and weak evidence about a common thing often changes nothing. Bayes' theorem is just the discipline of holding both numbers at once.
What this calculator does not cover
The second-test update assumes the two tests are independent. Two tests on the same person, the same sample or the same image often fail on the same cases, and then the updated figure is a ceiling, not an estimate.
Sensitivity and specificity are treated as exact. The page puts no uncertainty interval around them, so a test whose published figures come from a small study carries more doubt than the printed decimals suggest.
The multi-hypothesis mode needs priors that add to 100 percent and a likelihood for each hypothesis. It cannot compare explanations when the evidence cannot be scored under one of them, and it cannot invent a prior you do not have.
Prevalence must come from the population being tested. A figure borrowed from another age group, another country or a clinic with different referral patterns gives a posterior for that population, not yours.
This is a probability update, not a diagnosis. A positive result belongs with the clinician who ordered the test and knows your history.
Bayes theorem calculator FAQs
What does the posterior probability mean?
The posterior is the probability after the evidence has been counted: your starting probability, updated. Bayes' theorem computes it as P(B given A) times P(A), divided by P(B). After a positive test result it is the number people want: the chance the condition is really present, which is 16.67 percent on this page's default case, printed beside the prior it came from so you can see exactly what the evidence moved.
Why is a positive result on a 99 percent accurate test wrong so often?
It will miss about 1 in 100 people who have the condition (sensitivity 99 percent), and it will wrongly flag about 5 in 100 healthy people (specificity 95 percent). Whether your positive result is right depends on prevalence: at 1 percent prevalence only about 1 in 6 positive results is a true case, because the false positives from the healthy 99 percent outnumber the true positives.
What is the difference between sensitivity and specificity, and where does each go?
Sensitivity is a property measured on people who have the condition: of every 100 true cases, how many does the test catch? Specificity is measured on people who do not: of every 100 healthy people, how many does the test correctly clear? In the diagnostic form, sensitivity multiplies the prevalence to give the true positive stream, while 1 minus specificity, the false positive rate, multiplies the healthy remainder to give the false positive stream. None of the three says how common the condition is, which is why none of them alone can tell you what your positive result means.
What happens if I test positive twice?
If the two tests are genuinely independent, updating twice with a likelihood ratio of 19.8 moves the probability from 16.67 percent after one positive to 79.84 percent after two. In practice, repeat tests on the same person often share the same blind spots, so the real gain is usually smaller than the independence maths promises; treat 79.84 percent as the best case.
What is PPV, and why is it not the test's accuracy?
PPV is the probability that a person with a positive result has the condition: true positives divided by all positives. With prevalence 1 percent, sensitivity 99 percent and specificity 95 percent, that is 990 true positives out of 5,940 total positives per 100,000 people, which is 16.67 percent. Accuracy is a different count: every correct call, true positives plus true negatives, over everyone tested. A test can be about 95 percent accurate overall while most of its positive results are false alarms, which is the normal situation when the condition is rare.
Can Bayes theorem compare more than two explanations at once?
Yes. The multi-hypothesis mode splits the prior across as many causes as you list and reweights each by how well it explains the evidence: the total probability of the evidence is each prior times its likelihood, added up. With priors of 50, 30 and 20 percent and likelihoods of 90, 40 and 10 percent, the evidence total is 59 percent, and the posteriors come out at 76.27, 20.34 and 3.39 percent.
What if I do not know the prior probability?
Get it from the population being tested, not from the test box: published screening studies for that population, the clinic's own confirmed case rate, or a registry figure for the age and risk group. If no figure exists for your population, run the calculator at several prevalences, say 0.1, 1 and 10 percent, and report the range rather than a single borrowed number.
The sensitivity, specificity, predictive value framework follows Loong, T.W. (2003), Understanding sensitivity and specificity with the right side of the brain, BMJ 327: 716 to 719. The natural frequency presentation follows Gigerenzer and coauthors, Helping Doctors and Patients Make Sense of Health Statistics. Last verified 29 November 2026.
