Bayes Theorem Calculator
A free tool by DeepRit, a Google Ads agency that does PPC and nothing else. We build and run Google Ads accounts so every click is accounted for. Book a free audit call
Free Bayes theorem calculator. Enter the base rate, the true positive rate and the false positive rate to get the real probability after a positive result.
- P(B): positive results overall
- 0
- P(A | not B)
- 0
- Out of 1,000 people
- 0
Free, no sign-up. Runs in your browser: nothing you type is uploaded or saved.
How to use the Bayes theorem calculator
- Enter P(A), the prior: how likely A is before you see any evidence, as a percentage. In medical testing, this is the prevalence of the condition.
- Enter P(B | A), the true positive rate: how likely the evidence B is if A is true. For a test, this is its sensitivity.
- Enter P(B | not A), the false positive rate: how likely the evidence is if A is false. For a test, this is 100% minus its specificity.
The Bayes theorem calculator shows P(A | B), the probability that A is true given the evidence, as well as the overall rate of positive results P(B), the probability of A after a negative result, and what the numbers mean out of 1,000 people.
What is Bayes' theorem?
Bayes' theorem is a rule for updating a probability when you get new evidence. It's named after Thomas Bayes, an 18th-century English minister and mathematician whose essay on the subject was published after his death in 1763. Pierre-Simon Laplace developed the idea much further independently.
P(A | B) = P(B | A) × P(A) ÷ P(B)
where P(B) = P(B | A) × P(A) + P(B | not A) × (1 − P(A))
In words: the probability of A given B equals the probability of B given A, times the prior probability of A, divided by the overall probability of B.
The classic medical test example
Suppose 1% of people have a condition. A test detects it 90% of the time when it's present, but also gives a positive result to 9% of people who don't have it. You test positive. How likely is it that you have the condition?
Many people guess around 90%. The Bayes theorem calculator gives a very different answer:
- P(B), positive results overall: 0.9 × 0.01 + 0.09 × 0.99 = 0.0981, or 9.81%.
- P(A | B): 0.9 × 0.01 ÷ 0.0981 ≈ 9.17%.
Only about 9% of people who test positive actually have the condition. Out of 1,000 people, about 10 have it and 9 of those test positive. Of the 990 who don't, about 89 test positive anyway. So of roughly 98 positive results, only 9 are true positives.
Why the base rate matters
The surprising result comes from the base rate, the prior probability P(A). When a condition is rare, false positives from the large healthy group outnumber true positives from the small affected group, even with a fairly accurate test. Ignoring the base rate is a common error called the base rate fallacy, and it affects doctors, juries and the public alike. The Bayes theorem calculator makes the base rate explicit, so you can see how much it matters.
A worked example: a very accurate test
A test is 99% sensitive and has a false positive rate of only 1%. The condition affects 1 in 1,000 people (0.1%).
- P(B): 0.99 × 0.001 + 0.01 × 0.999 ≈ 0.01098, or about 1.098%.
- P(A | B): 0.99 × 0.001 ÷ 0.01098 ≈ 9.02%.
Even with a test that's 99% accurate in both directions, a positive result means only about a 9% chance of having the condition, because the condition is so rare. Out of 1,000 people, about 1 has it and tests positive, while about 10 healthy people test positive too. This is why positive screening results for rare conditions are usually confirmed with further tests. Enter 0.1, 99 and 1 in the Bayes theorem calculator to check.
Updating again with a second test
The posterior from one piece of evidence becomes the prior for the next. If a person who tested positive in the default example (posterior 9.17%) takes a second, independent test with the same characteristics and also tests positive, enter 9.17% as the new prior. The probability rises to about 50%. A third positive would take it to about 91%. This step-by-step updating is the heart of Bayesian reasoning.
Beyond medicine
Bayes' theorem applies to any situation where you update a belief based on evidence:
- Spam filters: if 40% of emails are spam, the word "prize" appears in 25% of spam and 2% of legitimate email, then an email containing "prize" is spam with a probability of about 89%.
- Fraud detection: how likely is a flagged transaction to be fraudulent, given the fraud rate and the system's false alarm rate?
- Quality control: how likely is a part to be faulty, given that an inspection flagged it?
- Legal reasoning: how strongly does a piece of forensic evidence point to guilt, given how common the evidence is among innocent people?
- Machine learning: naive Bayes classifiers apply the theorem to many features at once.
Who uses a Bayes theorem calculator
Statistics and probability students use it to understand conditional probability. Doctors and healthcare workers use it to interpret test results and explain them to patients. Data scientists and analysts use it to reason about classifiers, alerts and A/B tests. Lawyers, journalists and policymakers use it to avoid misreading statistical evidence.
Need more customers from Google?
This tool is free and runs in your browser. If your business also needs more leads or sales, Google Ads is where people search with their wallet out. DeepRit manages Google Ads for small and mid-size businesses, and only Google Ads. We check your account before we ever get on a call, then fix the structure, the keywords, the tracking and the ads, with month-to-month terms and no long contract. Book a free audit call.
Natural frequencies
Research by psychologists such as Gerd Gigerenzer has shown that people understand Bayesian problems much better when probabilities are expressed as natural frequencies: counts out of a fixed group, such as "10 out of 1,000 people have the condition; 9 of them test positive; 89 of the 990 without it also test positive". That's why the Bayes theorem calculator shows results out of 1,000 people as well as percentages. When explaining test results to patients or the public, natural frequencies are often the clearest way to communicate.
The negative result
Bayes' theorem also tells you what a negative result means. In the default example, the probability of having the condition after a negative result is only about 0.11%, down from 1% before the test. A negative result from a sensitive test is very reassuring when the condition is rare. The Bayes theorem calculator shows this as P(A | not B).
Prior probabilities in practice
The answer depends heavily on the prior, so choosing it carefully matters. For a medical test, the right prior is the prevalence in people like the one being tested, not in the whole population. A person with symptoms, a family history or other risk factors has a higher prior than a random member of the public, and a positive result means much more for them. Try the default example with a prior of 10% instead of 1%: the probability after a positive test rises from about 9% to about 53%.
Common mistakes
- Confusing P(A | B) with P(B | A), sometimes called the prosecutor's fallacy.
- Ignoring the base rate and assuming a positive test is as reliable as its sensitivity.
- Using the wrong prior, such as the whole-population rate for a high-risk patient.
- Treating correlated tests as independent when updating more than once.
Bayes' theorem with odds
There's a neat alternative form of Bayes' theorem that uses odds instead of probabilities:
Posterior odds = prior odds × likelihood ratio
The likelihood ratio for a positive result is the true positive rate divided by the false positive rate. In the default example, it's 90% ÷ 9% = 10. The prior odds are 1 to 99. Multiplying gives posterior odds of 10 to 99, which is a probability of 10 ÷ 109 ≈ 9.17%, the same answer as the Bayes theorem calculator. This form makes it easy to see that a test multiplies the odds by a fixed amount, so its effect depends entirely on where you start.
Bayes in A/B testing
Product and marketing teams increasingly use Bayesian methods to analyse experiments. Instead of asking whether a result is statistically significant, they ask how likely it is that version B is better than version A, given the data. The underlying idea is the same as in the Bayes theorem calculator: start with a prior belief, update it with the evidence, and report the resulting probability. Bayesian A/B testing uses probability distributions rather than single numbers, but the logic of updating is identical.
Sources and further reading
- Bayes' theorem on Wikipedia: statement, history and examples.
- Base rate fallacy on Wikipedia: why ignoring prior probabilities leads to errors.
- Stanford Encyclopedia of Philosophy: Bayes' theorem, a detailed explanation of the theorem and its interpretation.
Frequently asked questions
What does Bayes' theorem calculate?
The probability of a hypothesis given new evidence, from the prior probability and how likely the evidence is under each possibility.
Why is the answer so low for a good test?
When the condition is rare, false positives from the many healthy people outnumber true positives from the few with the condition.
What is the prior?
Your probability before seeing the evidence, such as the prevalence of a condition.
Can I use the result as a new prior?
Yes. For independent evidence, enter the posterior as the prior and update again.
Are the inputs percentages?
Yes. Enter each probability as a percentage, for example 1 for 1%.
Is the Bayes theorem calculator free?
Yes. It's free, needs no sign-up, and works in your browser.
Free PPC audit
See where your ad budget leaks.
We look at your Google Ads account before the call, then walk you through what we'd fix first, in dollars. No obligation, no hard sell.