We use cookies for analytics and personalized ads. We use cookies for basic analytics and, where we show ads, to personalize them. Privacy PolicyRead our Privacy Policy.
Bayes' theorem updates a belief after new evidence: P(A|B) = P(B|A) × P(A) / P(B). Use it for medical tests, spam filters (naive Bayes), machine learning and any "given that" question.
Each tab starts with a short guide for beginners, then a live calculator with step-by-step working. Your numbers never leave this browser.
The big idea: you already believe something (the prior). Then you see new evidence. Bayes tells you how far to move your belief, and the answer is often not what your gut says.
Picture 10,000 people instead of formulas. Split them into sick and healthy. Tests find most sick people, but they also wrongly flag a few healthy ones. When you get a positive, you are standing in the crowd of everyone who tested positive. The question is: how many of them are truly sick?
The trap: if the thing is rare, the healthy crowd is huge, so even a small false-alarm rate creates many false positives. That is why a "90% accurate" test can mean only a ~10% chance you are sick.
Try it: press Rare disease below, then change the prevalence from 1% to 20% and watch the posterior jump.
This is the same math as Bayes, just counted as people. Read it left to right.
Everyone who we see evidence B: teal is genuinely A, pink is a false alarm.
Step 1: Write down what you know
Prior P(A) = 1%, P(B | A) = 90%, P(B | not A) = 9%.
Step 2: How likely is the evidence overall? (total probability)
P(B) = P(B|A)·P(A) + P(B|not A)·P(not A)
= 0.9 × 0.01 + 0.09 × 0.99 = 0.0981
Two ways to see B: A is true and B shows up, or A is false and B shows up anyway. We add both.
Step 3: Apply Bayes' theorem
P(A | B) = P(B|A)·P(A) / P(B)
= 0.009 / 0.0981 = 9.17%
Step 4: Check it with people
981 people we see evidence B. Only 90 of them really are A. 90 / 981 = 9.17%. Same answer, easier to picture.
Step 5: What it means
The evidence raised your belief from 1% to 9.17%, but that is much lower than 90%. P(B|A) and P(A|B) are different things. The low prior (base rate) is holding the answer down.
The Bayes and Medical Test tabs use P(A|B) = P(B|A)·P(A) / [P(B|A)·P(A) + P(B|¬A)·P(¬A)]. The spam tab applies naive Bayes with Laplace smoothing and sums log-probabilities to avoid underflow. The table tab divides a cell by the grand total for joint probability, or by a row or column total for conditional probability. The ML tab shows Beta-Binomial updating, where the posterior is the prior plus the observed counts.
Results update live as you type. Values are for learning and are not medical or legal advice.