Formula: Bayes Theorem Mathematical Identity
- priorPct: Prior Pct (%)
- sensitivityPct: Sensitivity Pct (%)
- falsePositivePct: False Positive Pct (%)
Update prior probability P(A) with sensitivity P(B|A) and false-positive rate P(B|¬A).
From the best estimate of how common the condition is among people like the one being tested, before the test result is known. For a screening programme that might be population prevalence. For a patient with symptoms, a clinician would use a higher, situation-specific figure. The answer is very sensitive to this input, so a vague prior gives a vague posterior.
Yes. Specificity is the share of people without the condition who correctly test negative. The rest test positive, so the false-positive rate is 100 minus specificity. The default 8% corresponds to 92% specificity. Enter the false-positive rate, not the specificity, in the third field, or the result will be badly wrong.
P(B) is the share of all tested people who come back positive. In the default it is 12.35%. It is the denominator of the posterior, and it is also practical: it tells you how many follow-up investigations a screening programme should expect. If you run 100 tests you would expect about 12 positives, most of them false alarms.
Yes. Any situation with a base rate, a hit rate and a false-alarm rate fits. A fraud alert, a quality inspection flagging faulty parts, a spam filter or a witness identification can all be framed this way. A is the thing you care about, B is the signal you observed, and the three inputs describe how often B appears with and without A.
For the positive predictive value shown here, sensitivity matters most when the prior is high. With a 50% prior, true and false positives come from groups of equal size, so losing true positives costs as much as gaining false ones. Sensitivity also matters a great deal for the negative predictive value, where missing cases is the main risk.
Not necessarily. The posterior went from 5% to 38.462%, nearly an eightfold rise, which is a big change in what you know. The test is doing its job. The low absolute number reflects the low starting point. Whether it is good enough depends on what happens next, such as whether a confirmatory test exists and how costly false alarms are.
That a positive result is 11.875 times more common among people with the condition than among those without it. Multiplying prior odds by that figure gives posterior odds. Ratios above about 10 are usually regarded as strong evidence, though a strong ratio can still leave a modest posterior when the prior is small.
Because negatives are dominated by the large healthy group. In the default, 87.4 of every 100 people are healthy and test negative, against only 0.25 sick people who are missed. The negative predictive value is 99.715%, and it only falls noticeably when the prior is high: entering 38.462% as the prior brings it down to 96.715%.
Yes, if they are reasonably independent. Use the first posterior as the prior and enter the second test's sensitivity and false-positive rate. If both tests share a weakness, such as reacting to the same interfering substance, chaining will overstate confidence because the second result is not really new evidence.
No. The calculator shows how the probability arithmetic works with the numbers you give it. Real diagnostic decisions also depend on symptoms, test quality in a specific lab, the harms of treatment and of missed diagnosis, and further testing. Use it to understand a result, and discuss the actual decision with a qualified clinician.
Because the prior is the input whose effect people most often underestimate, so varying it shows the key lesson quickly: with the test held fixed, the posterior moves from 26.861% at a 3% prior to 49.053% at 7.5%. To see the effect of a better test instead, keep the prior at 5% and lower the false-positive rate yourself.
The default scenario is the classic one that surprises people. A condition affects 5% of the group being tested. The test catches 95% of true cases, and it wrongly flags 8% of people who do not have the condition. Someone tests positive. How likely is it that they actually have it?
The calculator's answer is 38.462%. Most people's first guess is somewhere near 95%, because that is the number attached to the test. The gap between those two figures is the whole reason Bayes' theorem is worth learning.
The test's 95% describes how often a sick person tests positive. The question is the other way round: how often a positive person is sick. Those two conditional probabilities can be very different, and the thing that links them is how common the condition was to begin with.
Psychologists call the usual mistake base-rate neglect. People focus on the vivid, specific number, the accuracy of the test, and quietly ignore the dull background number, how rare the condition is. The calculator forces the background number into the sum by making the prior the first input, which is a useful habit to carry into any judgement that starts from a positive signal.
Picture 100 people from the group. With a 5% prior, 5 have the condition and 95 do not.
Of the 5 with the condition, 95% test positive, which is 4.75 people. Of the 95 without it, 8% test positive anyway, which is 7.6 people. So 12.35 out of every 100 people test positive in total. That is the second supporting line on the page, total evidence probability P(B) of 12.35%.
Only 4.75 of those 12.35 positives are real. Divide one by the other and you get 0.3846, the 38.462% posterior. In plain terms, out of every 13 or so positive results, about 5 are true and about 8 are false alarms.
The formula on the page does exactly this with fractions instead of people: sensitivity times prior, divided by that same quantity plus the false-positive rate times one minus the prior. Working through the hundred-person version once makes it much easier to trust the result, and to spot when an input has been typed wrongly.
The page's own presets change only the prior, and the posterior swings widely. At a 3% prior it is 26.861%. At the default 5% it is 38.462%. At 7.5% it rises to 49.053%. The test has not changed at all; only the group being tested has.
Push further and the effect is stark. With a 1% prior the posterior falls to 10.71%, and with a 0.1% prior it is about 1.2%. In that last case, nearly every positive result is a false alarm, even though the test is the same one that gives 38% in the default group.
At the other end, a 50% prior gives a posterior of 92.233%. That is the situation where someone is already strongly suspected of having the condition, perhaps because of symptoms, and the test is confirming rather than screening.
This is why the same test can be useful in a clinic and nearly useless as a mass screen. Before using the result, think hard about which prior genuinely applies to the person or item being tested, not the prior for the population as a whole.
A useful check on any prior is to ask what would have prompted the test. A person sent for testing because of a family history or a symptom belongs to a group where the condition is more common than in the population at large, so a population figure would understate their prior and understate the posterior with it.
When the condition is rare, the false-positive rate dominates. That is because it applies to the large group without the condition. In the default, 8% of 95 people is 7.6 false alarms, which outnumbers the 4.75 true positives.
Cut the false-positive rate from 8% to 1% and the posterior jumps from 38.462% to 83.333%. Now only 0.95 of every 100 people are false alarms, fewer than the true positives.
Sensitivity has a smaller effect. Dropping it from 95% to 80% at the default prior and false-positive rate brings the posterior only to 34.483%. Losing some true positives hurts a little, but they were never the main problem.
So if you are comparing two tests for a low-prevalence screen, the one with the lower false-positive rate, often described as higher specificity, will usually give the more trustworthy positive result, even if its sensitivity is a bit worse. A test with 99% sensitivity and a 2% false-positive rate gives 72.263% at the default prior.
The last supporting line is the positive likelihood ratio, LR+, which is sensitivity divided by the false-positive rate. For the default, 95 divided by 8 is 11.875. It tells you how many times more likely a positive result is in someone with the condition than in someone without it.
The page marks it with a multiplication sign, 11.875 ×, because it is a plain ratio rather than a percentage. When the false-positive rate is zero the ratio would be infinite, so the page hides this line rather than print a meaningless figure.
The likelihood ratio gives a neat shortcut through the odds form of Bayes. Convert the prior to odds: 5 to 95, or about 0.053. Multiply by LR+ to get posterior odds of about 0.625. Convert back with odds divided by one plus odds, and you get 0.3846, the same 38.462%.
An LR+ of 1 means the test tells you nothing. Set sensitivity and false-positive rate both to 8% and the page shows a likelihood ratio of 1 and a posterior of exactly 5%, the same as the prior. Higher ratios mean more informative positives.
The posterior is the positive predictive value. The last line on the page is its counterpart, the negative predictive value: the chance that someone who tests negative is truly clear. For the default it reads 99.715%, and the hundred-person picture shows where that comes from.
In the default group, 0.25 of the 5 sick people test negative (the 5% the test misses). Of the 95 healthy people, 92% test negative, which is 87.4. So about 87.65 people test negative, and 87.4 of them are truly clear. Divide and you get the 99.715% on the page. Across the presets it barely moves, from 99.832% at a 3% prior to 99.561% at 7.5%, while the positive predictive value swings widely.
This asymmetry is typical of a rare condition. A negative result is very reassuring, while a positive result is a reason to look further rather than a diagnosis. Screening programmes are usually designed around exactly that pattern, with a positive screen followed by a more specific confirmation test.
Bayes' theorem chains naturally. The posterior from one piece of evidence becomes the prior for the next. If the default person takes a second, independent test with the same characteristics and it also comes back positive, enter 38.462 as the new prior. The page then reports 88.126%.
The important word is independent. A repeat of the same test on the same sample often fails for the same reason the first one did, so its errors are correlated, and chaining it as though it were new evidence will overstate the confidence. A different kind of test, with a different source of false positives, is much closer to the independence the arithmetic assumes.
The same chaining works outside medicine. Spam filters, fraud flags and fault detectors all combine several weak signals this way, with each signal's likelihood ratio nudging the odds up or down.
Order does not matter when the tests really are independent. Running the second test first and the default test second gives the same final figure, because each update simply multiplies the odds by its own likelihood ratio. Two positives at an LR+ of 11.875 each multiply the prior odds by 11.875 squared. Starting from odds of about 0.053, that lands near 7.4 to 1 in favour, which converts back to the 88.126% the page shows. Working in odds like this is often quicker than re-running the full formula for each test.
The false-positive field is the rate among those without the condition, P(B|not A). It is not the share of positive results that turn out false, which is what the calculator is computing for you. If a source quotes specificity, subtract it from 100 to get the value to enter: 92% specificity means an 8% false-positive rate.
All three inputs are percentages. Typing 0.05 for a 5% prior means 0.05%, a hundred times smaller, and the posterior will drop sharply.
The page rejects impossible edges rather than guessing. A prior of exactly 0 or 100 asks you to check inputs, since no evidence could change a certainty. A false-positive rate of 0 is accepted and gives a posterior of exactly 100%, because every positive must then be real; the likelihood ratio line disappears in that case. Real tests are never perfect, so treat that result as a limit, not a forecast.