ProbCalcProbability › Bayes' Theorem

Bayes' Theorem Calculator

Update a starting probability once new evidence comes in. Enter a prior probability, a test's sensitivity, and either its false positive rate or specificity, and get P(A|B), the positive predictive value, and a full breakdown of true and false results across a sample population.

Enter your scenario

Specificity = 1 − false positive rate. A 95%-specific test has a 5% false positive rate, so both toggles describe the same thing from opposite sides.
Your step-by-step Bayes' Theorem solution will appear here once you calculate.

What Bayes' Theorem is actually doing

Bayes' Theorem answers one specific kind of question: you start believing something is true with some probability, you observe a piece of evidence, and you want to know how that evidence should change what you believe. The starting belief is called the prior, P(A). The updated belief, after seeing the evidence, is called the posterior, P(A|B).

The counterintuitive part, and the reason this calculator exists, is that the posterior often lands much lower than people expect, even when the evidence seems strong. A test can be genuinely excellent and still produce more false alarms than real detections, purely because of how rare the thing being tested for is. That single fact, more than the algebra, is what trips people up.

The formula, and the pieces that make it up

Bayes' Theorem
P(A|B) = P(A) × P(B|A) / P(B)
P(A) is the prior. P(B|A) is the sensitivity, how often the test catches a true case. P(B) is the total probability of a positive result, whether or not A is actually true.
Law of Total Probability
P(B) = P(A)×P(B|A) + P(A')×P(B|A')
This is how P(B) gets built: add the positive results among people who have the condition to the positive results among people who don't.
Positive Predictive Value (PPV)
PPV = P(A|B)
PPV is just another name for the answer Bayes' Theorem gives you here: given a positive result, what fraction of those people actually have the condition.
Negative Predictive Value (NPV)
NPV = P(not A | negative result)
The mirror image of PPV: given a negative result, what fraction of those people genuinely don't have the condition.

Two worked examples

A rare disease. 1% of a population has a condition. A test correctly flags 95% of true cases (sensitivity) and wrongly flags 5% of healthy people (false positive rate). Someone tests positive. Out of 10,000 people: 100 actually have the condition, and the test correctly catches 95 of them. Of the 9,900 healthy people, 5% still test positive by mistake, which is 495 people. Total positives: 590. Of those, only 95 are genuinely sick. PPV = 95/590, about 16%.

A common condition. Now suppose 30% of a population has some condition (not rare at all), tested with a less precise instrument: 90% sensitivity, 10% false positive rate. Out of 1,000 people, 300 have the condition, and the test catches 270 of them. Of the 700 without it, 10% test positive anyway, which is 70 people. Total positives: 340. Of those, 270 are genuine, so PPV = 270/340, about 79%. Same test quality logic, wildly different reliability, purely because the condition isn't rare this time.

These two examples use the same style of math but land in completely different places. That gap is the entire point of running the numbers instead of trusting intuition.

Mistakes people make with Bayes' Theorem

Confusing sensitivity with PPV. "95% accurate" almost always refers to sensitivity, how well the test catches true cases, not to PPV, how trustworthy a positive result is. These are different numbers answering different questions, and mixing them up is the single biggest source of Bayes' Theorem confusion.

Ignoring the prior entirely. A test's accuracy numbers stay fixed, but PPV moves a lot depending on how common the condition is in whoever's being tested. The same test gives a very different PPV in a high-risk population versus a general screening of everyone.

Treating specificity and false positive rate as if they need separate calculations. They're the same information. Specificity = 1 minus the false positive rate. Whichever one a source gives you, converting to the other takes one subtraction.

Questions people actually ask about this

Why is PPV so much lower than the test's sensitivity?

Sensitivity only describes performance among people who actually have the condition. PPV describes performance among everyone who tested positive, including false alarms from the much larger group of healthy people. When the condition is rare, that larger group produces enough false positives to swamp the true ones, dragging PPV down even for a highly sensitive test.

What's the difference between sensitivity and specificity?

Sensitivity is how well a test catches true cases: P(positive | has condition). Specificity is how well it correctly clears healthy people: P(negative | no condition). A test can be strong on one and weak on the other.

Does running the same test twice improve reliability?

Yes, substantially, provided the two tests aren't correlated in their errors. Feeding the posterior probability from the first test back in as the new prior for a second test is exactly how Bayesian updating is meant to be used, and it's why doctors often confirm a positive result with a second, different type of test.

Can P(A|B) ever equal P(A)?

Yes, if the evidence B is completely uninformative about A. That happens when P(B|A) equals P(B|not A), meaning the test is no better than a coin flip at distinguishing the two groups.

Why does the calculator ask for sample size?

Purely to make the breakdown table concrete. The underlying probabilities don't depend on sample size at all, but seeing "590 positives, 95 genuine" out of 10,000 people is far easier to reason about than raw percentages alone.

Built for quick, checkable probability work. Always confirm your inputs match the scenario you're modelling.