What is a Bayes’ Theorem Calculator?
A Bayes’ theorem calculator updates a prior probability P(A) with new evidence B. Enter how common A is, the sensitivity P(B | A) and the false-positive rate P(B | not A), the specificity or P(B) itself, and it returns the posterior P(A | B) = P(B | A)·P(A) / P(B), with the steps, the Bayes factor and a natural-frequency table.
What the Bayes’ Theorem Calculator does
Bayes’ theorem (also called Bayes’ rule or Bayes’ formula) turns “how likely is the evidence if the hypothesis is true?” into “how likely is the hypothesis now that I have seen the evidence?”. The classic case is a medical test: you know the prevalence of the disease (the prior), the test’s sensitivity and its specificity, and you want the chance that a person who tests positive actually has the disease. That chance is the posterior probability, also called the positive predictive value.
The calculator shows each step: the total probability of the evidence, the posterior, the probability of A after a negative result, the odds form with the Bayes factor, and a table of what happens to 10,000 people. That table makes the answer intuitive, and it shows why a positive result for a rare condition is often a false alarm. If you already know the joint probability P(A ∩ B) and P(B), you do not need Bayes’ theorem; use the Conditional Probability Calculator instead.
How to use the Bayes’ Theorem Calculator
- Enter Prior probability, P(A): how common A is before the evidence, such as a disease prevalence of 0.01 (1%). Decimals, fractions and percentages all work.
- Enter Sensitivity, P(B | A): how often the evidence appears when A is true, such as 0.95 for a test that catches 95% of cases.
- Under What else do you know?, pick False-positive rate and enter P(B | not A), pick Specificity and enter P(not B | not A), or pick P(B) if your problem gives the overall probability of the evidence, as many textbook problems do.
- Read the posterior P(A | B), then check the natural-frequency table and the step-by-step solution to see the true and false positives behind it.
Sensitivity, specificity and predictive values in Bayes’ terms
Medical tests and Bayes’ theorem use different names for the same quantities. The table maps each test term to the probability the calculator uses, with the values from the screening example below (1% prevalence, 95% sensitivity, 90% specificity).
| Test term | Bayes’ notation | Screening example |
|---|---|---|
| Prevalence (base rate) | P(A), the prior | 0.01 |
| Sensitivity (true-positive rate) | P(B | A) | 0.95 |
| Specificity (true-negative rate) | P(not B | not A) | 0.90 |
| False-positive rate | P(B | not A) = 1 − specificity | 0.10 |
| Positive predictive value | P(A | B), the posterior | 0.0876 |
| Negative predictive value | P(not A | not B) | 0.9994 |
| Bayes factor, LR+ | P(B | A) / P(B | not A) | 9.5 |
Bayes’ theorem formula
| Symbol | Meaning |
|---|---|
| P(A) | prior: probability of A before seeing the evidence (prevalence, base rate) |
| P(B | A) | likelihood: chance of the evidence when A is true (sensitivity) |
| P(B | not A) | chance of the evidence when A is false (false-positive rate = 1 − specificity) |
| P(B) | total probability of the evidence, from both routes |
| P(A | B) | posterior: probability of A after seeing B (positive predictive value) |
Odds and probabilities convert with odds = p / (1 − p) and p = odds / (1 + odds).
Bayes’ theorem example
Worked example: a screening test
Problem. A condition affects 1% of people. A screening test detects it 95% of the time (sensitivity 0.95) and has a specificity of 90%, so it gives a false positive for 10% of healthy people. If someone tests positive, what is the probability they have the condition?
- 01False-positive rate: P(B | not A) = 1 − 0.90 = 0.10.
- 02Total probability of a positive: P(B) = 0.95 × 0.01 + 0.10 × 0.99 = 0.0095 + 0.099 = 0.1085.
- 03Posterior: P(A | B) = 0.0095 / 0.1085 = 0.0876.
- 04Natural frequencies: of 10,000 people, 100 have the condition and 95 of them test positive; of the 9,900 without it, 990 test positive. So 95 of the 1,085 positives are real: 95 / 1,085 = 0.0876.
- 05After a negative result: P(A | not B) = 0.05 × 0.01 / 0.8915 = 0.000561, down from 0.01.
Answer. A positive result raises the probability from 1% to only about 8.76%, because the 990 false positives from the large healthy group swamp the 95 true positives. A negative result makes the condition very unlikely (about 0.06%).
The base-rate fallacy
People presented with a “95% accurate” test tend to guess that a positive result means a 95% chance of disease. That guess ignores the base rate: when only 1 person in 100 has the condition, the healthy 99 produce far more false positives than the sick 1 produces true positives. Neglecting the prior in this way is called the base-rate fallacy.
The fix is to always ask how common the condition is in the group being tested. The same test used in a clinic where 30% of patients have the condition gives a posterior of about 0.80, not 0.09. Change Prior probability, P(A) above to see how strongly the answer depends on it.
Updating again with a second result
Bayes’ theorem can be applied repeatedly. After one positive result the posterior becomes the new prior for the next, independent piece of evidence. In the example, a second positive from an independent test with the same accuracy raises the probability from 0.0876 to about 0.48, which is why screening programs confirm positives with a second test.
Bayes’ theorem with more than two hypotheses
The calculator compares one hypothesis A with its complement. When there are three or more hypotheses H₁, H₂, …, Hₖ that cannot happen together and cover every possibility, the same rule applies to each one: P(Hᵢ | B) = P(B | Hᵢ)·P(Hᵢ) / Σ P(B | Hⱼ)·P(Hⱼ). Multiply each prior by its likelihood, then divide each product by the sum of all of them.
Example: three machines make 50%, 30% and 20% of a factory’s parts, with defect rates of 1%, 2% and 3%. A part is found to be defective. The products are 0.005, 0.006 and 0.006, which add up to P(defective) = 0.017.
| Machine | Prior P(Hᵢ) | Defect rate P(B | Hᵢ) | Product | Posterior P(Hᵢ | B) |
|---|---|---|---|---|
| 1 | 0.50 | 0.01 | 0.005 | 0.005 / 0.017 = 0.2941 |
| 2 | 0.30 | 0.02 | 0.006 | 0.006 / 0.017 = 0.3529 |
| 3 | 0.20 | 0.03 | 0.006 | 0.006 / 0.017 = 0.3529 |
Common use cases
- Medical testing: the positive predictive value of a screening test for a given prevalence.
- Spam and fraud filters: the probability a message is spam given that it contains a certain word or pattern.
- Quality control: the chance a part is defective given that an inspection flagged it.
- Forensics and law: weighing how much a piece of evidence should change belief in a hypothesis, and avoiding the prosecutor’s fallacy.
- Machine learning: the reasoning behind naive Bayes classifiers and posterior class probabilities.
Assumptions and limitations
- The posterior is only as reliable as the prior. A prevalence taken from the general population is the wrong prior for a high-risk group or a patient with symptoms.
- P(B | A) and P(B | not A) must come from the same definition of “positive” and from a population like yours; sensitivity and specificity measured in a hospital may not transfer to screening.
- This calculator handles one hypothesis versus its complement. With three or more competing hypotheses, apply the theorem to each one and divide by the sum, as shown in the section on more than two hypotheses.
- Repeated updating assumes the pieces of evidence are conditionally independent; two tests that share the same failure mode do not count as two independent confirmations. For the plain definition of conditional probability, see the Conditional Probability Calculator.
Frequently asked questions
What does Bayes’ theorem calculate?
Why is the chance of disease so low after a positive test?
What is the difference between sensitivity, specificity and the false-positive rate?
What are the prior and the posterior in Bayes’ theorem?
What is a likelihood ratio or Bayes factor?
Can I use specificity instead of the false-positive rate?
Can I enter P(B) directly?
How do you calculate Bayes’ theorem by hand?
Cite this page
Statculator. (2026, November 14). Bayes’ Theorem Calculator. Retrieved November 14, 2026, from https://statculator.com/probability/bayes-theorem-calculator/