Bayes' Theorem Calculator

Calculate conditional probability with Bayes' theorem from prior, likelihood, and evidence.
Includes a worked medical test sensitivity and specificity example.

How likely A was before you saw B. This is the number people forget, and forgetting it is what base rate neglect means.
How common the disease is in the population being tested. Screening the general public and testing people with symptoms are very different numbers.
Posterior Probability

Bayes’ Theorem P(A|B) = P(B|A) × P(A) / P(B) Or equivalently: Posterior = (Likelihood × Prior) / Evidence Named after Thomas Bayes (England, c. 1763), refined by Pierre-Simon Laplace.

Terms Explained P(A) = Prior probability: probability of A before observing B. P(B|A) = Likelihood: probability of observing B given that A is true. P(A|B) = Posterior: probability of A being true after observing B. P(B) = Evidence (marginal probability): P(B) = P(B|A)×P(A) + P(B|¬A)×P(¬A)

Medical Test Example A test for a disease with: Prevalence (prior): P(disease) = 1% → P(A) = 0.01 Sensitivity (true positive rate): P(positive | disease) = 95% → P(B|A) = 0.95 Specificity: P(negative | no disease) = 90% → P(B|¬A) = 1 - 0.90 = 0.10 Result: P(disease | positive test) = (0.95 × 0.01) / ((0.95 × 0.01) + (0.10 × 0.99)) ≈ 8.76% This counterintuitive result shows how low prevalence reduces positive predictive value.

The same example in whole people, which is much easier to see. Take 10,000 people. About 100 have the disease and 9,900 do not. Of the 100 sick, the test catches 95. Of the 9,900 healthy, it wrongly flags 990. So 1,085 people test positive and only 95 of them are actually ill, which is 8.76%. Nothing about that calculation needs Bayes’ theorem written out. Counting people is the same arithmetic in a form the reader can check on their fingers, and the result panel shows both.

Bayesian Updating Each new piece of evidence updates the probability: New posterior = P(A|new evidence) from current prior. The prior of the next calculation becomes the previous posterior. That iterative process is Bayesian inference, and it is the engine under machine learning, spam filters, medical diagnosis and ordinary scientific reasoning.

Bayes Factor BF = P(B|H₁) / P(B|H₀) The ratio of likelihoods for two hypotheses. BF > 3: moderate evidence for H₁. BF > 10: strong evidence. Note what the Bayes factor does not include: the prior. It measures only how much the evidence should move you, not where you end up, which is why a test with a huge Bayes factor can still leave a rare disease unlikely.

A second example, spam filtering. Say 20% of incoming mail is spam, and the word “lottery” turns up in 60% of spam but only 1% of legitimate mail. An email containing “lottery” is spam with probability (0.60 × 0.20) / (0.60 × 0.20 + 0.01 × 0.80) ≈ 93.75%. Chaining many word-level probabilities like this is exactly how a naive Bayes spam classifier scores a whole message.

The trap to avoid: base rate neglect. The most common mistake in everyday probability reasoning is ignoring the prior. Shown a “99% accurate” test for a rare disease, most people blurt out “99% chance you have it” and forget how rare the disease is to begin with. Bayes’ theorem is the antidote: it forces the base rate and the test result to be combined, instead of reading the test result on its own.


How we build and check this calculator

This calculator runs entirely in your browser, so the numbers you enter stay on your device. The math behind it is written by hand and tested against worked examples and standard references before the page goes live.

SuperGlobalCalculator is independently built and maintained. See how we build and verify our calculators.


Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.