Skip to content
Statculator
Probability & Counting

Bayes’ Theorem Calculator

Free Bayes’ theorem calculator. Enter the prior, sensitivity and specificity or false-positive rate for the posterior P(A|B), with steps and a frequency table.

Free, no sign-up Runs in your browserBy Hira Noor, BS MathematicsUpdated

Try

How common A is before you see the evidence, such as the prevalence of a disease. 1% can be typed as 0.01, 1/100 or 1%.

Chance of seeing the evidence when A is true: a test’s sensitivity or true-positive rate.

What else do you know?

Chance of seeing the evidence when A is false. Equals 1 − specificity.

Results

Posterior P(A | B)
0.0876
Probability of A after seeing B, the positive predictive value (8.76%)
P(A | not B)
0.0006
Probability of A when the evidence is absent
P(B), total probability of the evidence
0.1085
Specificity P(not B | not A) = 1 − false-positive rate
0.9
P(not A | B), false-discovery share
0.9124
P(not A | not B), negative predictive value
0.9994
Bayes factor (likelihood ratio LR+) = P(B | A) / P(B | not A)
9.5
Likelihood ratio LR− = P(not B | A) / P(not B | not A)
0.0556
Prior odds of A
0.0101
Posterior odds of A given B
0.096
Posterior ÷ prior
8.7558

Interpretation: Seeing B raises the probability of A from 1% to 8.76%. In a group of 10,000, about 1,085 would show B, and 95 of them would actually have A.

  • Base-rate effect: even though B is 9.5 times more likely when A is true, A is rare to begin with, so false positives (990 per 10,000) outnumber true positives (95 per 10,000).
Bar chart of 3 categories0.000.020.040.060.080.10Probability of APrior P(A): 0.010.01Prior P(A)Posterior P(A | B): 0.08760.0876Posterior P(A | B)P(A | not B): 0.00060.0006P(A | not B)
How the evidence moves the probability of A.

Natural frequencies per 10,000 people

B (positive)not B (negative)Total
A (has the condition)955100
not A9908,9109,900
Total1,0858,91510,000

Of the 1,085 people with a positive result, 95 have A: 95 / 1,085 = 0.0876. Of the 8,915 negatives, 5 have A.

Step-by-step solution

  1. 1

    Find the total probability of the evidence, P(B)

    B can happen with A (true positives) or without A (false positives). Add both routes.

    P(B) = P(B | A) · P(A) + P(B | not A) · P(not A)
    P(B) = 0.95 × 0.01 + 0.1 × 0.99 = 0.0095 + 0.099 = 0.1085
  2. 2

    Apply Bayes’ theorem

    The posterior is the share of all B outcomes that come from A.

    P(A | B) = P(B | A) · P(A) / P(B)
    P(A | B) = 0.0095 / 0.1085 = 0.0876
  3. 3

    Find the probability of A when B is absent

    P(A | not B) = P(not B | A) · P(A) / P(not B)
    P(A | not B) = (1 − 0.95) × 0.01 / (1 − 0.1085) = 0.0005 / 0.8915 = 0.0006
  4. 4

    Check with the odds form

    Posterior odds = prior odds × likelihood ratio. Converting the odds back to a probability gives the same answer.

    Prior odds = 0.01 / 0.99 = 0.0101
    LR+ = 0.95 / 0.1 = 9.5
    Posterior odds = 0.0101 × 9.5 = 0.096
    P(A | B) = odds / (1 + odds) = 0.0876
  5. 5

    Read the same result as natural frequencies

    Of 10,000 people: 100 have A, 9,900 do not
    True positives = 100 × 0.95 = 95
    False positives = 9,900 × 0.1 = 990
    P(A | B) = 95 / (95 + 990) = 0.0876

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

  1. 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.
  2. 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.
  3. 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.
  4. 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 termBayes’ notationScreening example
Prevalence (base rate)P(A), the prior0.01
Sensitivity (true-positive rate)P(B | A)0.95
Specificity (true-negative rate)P(not B | not A)0.90
False-positive rateP(B | not A) = 1 − specificity0.10
Positive predictive valueP(A | B), the posterior0.0876
Negative predictive valueP(not A | not B)0.9994
Bayes factor, LR+P(B | A) / P(B | not A)9.5

Bayes’ theorem formula

Bayes’ theorem
P(A | B) = P(B | A) · P(A) / P(B)
Law of total probability
P(B) = P(B | A) · P(A) + P(B | not A) · P(not A)
From specificity
P(B | not A) = 1 − specificity
Negative evidence
P(A | not B) = [1 − P(B | A)] · P(A) / [1 − P(B)]
Odds form
posterior odds = prior odds × Bayes factor, Bayes factor = LR+ = P(B | A) / P(B | not A)
Formula symbols
SymbolMeaning
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?

  1. 01False-positive rate: P(B | not A) = 1 − 0.90 = 0.10.
  2. 02Total probability of a positive: P(B) = 0.95 × 0.01 + 0.10 × 0.99 = 0.0095 + 0.099 = 0.1085.
  3. 03Posterior: P(A | B) = 0.0095 / 0.1085 = 0.0876.
  4. 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.
  5. 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.

MachinePrior P(Hᵢ)Defect rate P(B | Hᵢ)ProductPosterior P(Hᵢ | B)
10.500.010.0050.005 / 0.017 = 0.2941
20.300.020.0060.006 / 0.017 = 0.3529
30.200.030.0060.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?

Bayes’ theorem calculates the probability of a hypothesis A after observing evidence B, written P(A | B). It combines the prior probability of A with how likely the evidence is when A is true and when A is false: P(A | B) = P(B | A)·P(A) / P(B).

Why is the chance of disease so low after a positive test?

Because the condition is rare. When the prevalence is 1%, the 99% of healthy people generate many false positives even with a modest false-positive rate. With a 10% false-positive rate, 990 of every 10,000 people test positive falsely compared with 95 true positives, so only about 8.8% of positives are real.

What is the difference between sensitivity, specificity and the false-positive rate?

Sensitivity is P(positive | condition), the share of true cases the test catches. Specificity is P(negative | no condition), the share of healthy people correctly cleared. The false-positive rate is 1 − specificity, P(positive | no condition), and it is the value this calculator asks for in the P(B | not A) field.

What are the prior and the posterior in Bayes’ theorem?

The prior P(A) is your probability for A before seeing the new evidence, often a base rate or prevalence. The posterior P(A | B) is the updated probability after taking the evidence into account. Today’s posterior becomes tomorrow’s prior when more evidence arrives.

What is a likelihood ratio or Bayes factor?

The positive likelihood ratio LR+ = P(B | A) / P(B | not A) says how many times more likely the evidence is when A is true than when A is false. When the two hypotheses are A and not A, it is also the Bayes factor. Multiplying the prior odds by LR+ gives the posterior odds, so an LR+ of 9.5 multiplies the odds of A by 9.5, whatever the prior.

Can I use specificity instead of the false-positive rate?

Yes. Choose Specificity under the sensitivity field and enter it directly. The false-positive rate is 1 − specificity, so a specificity of 0.93 is the same as a false-positive rate of 0.07, and the step-by-step solution shows the conversion.

Can I enter P(B) directly?

Yes. Choose P(B) under What else do you know? and the calculator uses P(A | B) = P(B | A)·P(A) / P(B) directly. For P(A) = 0.3, P(B | A) = 0.6 and P(B) = 0.4, the posterior is 0.18 / 0.4 = 0.45. It also works out the implied P(B | not A) = (0.4 − 0.18) / 0.7 = 0.3143.

How do you calculate Bayes’ theorem by hand?

Multiply the sensitivity by the prior to get P(B ∩ A). Multiply the false-positive rate by 1 − prior to get P(B ∩ not A). Add the two to get P(B), then divide the first product by P(B). With a 1% prior, 0.95 sensitivity and a 0.10 false-positive rate: 0.0095 / (0.0095 + 0.099) = 0.0876.

Cite this page

Statculator. (2026, November 14). Bayes’ Theorem Calculator. Retrieved November 14, 2026, from https://statculator.com/probability/bayes-theorem-calculator/