Quick answer
Bayes' theorem gives P(A|B) = P(B|A)P(A) ÷ [P(B|A)P(A) + P(B|¬A)P(¬A)]. With a prior of 1%, a test sensitivity of 90% and a false-positive rate of 5%, a positive result means only a 15.38% chance of the condition.
Enter the prior and the two likelihoods. The calculator returns the posterior probability and P(B).
Related tools: Probability Calculator: Probability of A and B, and A or B, for independent or mutually exclusive events. Dice Average Calculator: Average, minimum and maximum of rolling several dice. Permutation and Combination Calculator: Number of permutations and combinations of r items from n.
How to use the Bayes' Theorem Calculator
- Enter prior P(A) (between 0 and 1).
- Enter p(B | A) (between 0 and 1).
- Enter p(B | not A) (between 0 and 1).
- Press Calculate to see the result, and use Reset to start again.
| Input | What to enter | Allowed values |
|---|---|---|
| Prior P(A) | A number | ≥ 0, ≤ 1 |
| P(B | A) | A number | ≥ 0, ≤ 1 |
| P(B | not A) | A number | ≥ 0, ≤ 1 |
Formula and method
Formula
P(A | B) = P(B|A)P(A) ÷ [P(B|A)P(A) + P(B|¬A)P(¬A)]
IEEE-754 double precision; shown to at most 6 decimal places.
Law of total probability for the denominator.
Worked examples
This example is verified: each one is an automated test case that the live calculator must reproduce exactly.
Example 1
Inputs: Prior P(A) = 0.01; P(B | A) = 0.9; P(B | not A) = 0.05.
| Result | Value |
|---|---|
| P(A | B) | 0.153846 |
| P(B) | 0.0585 |
The first line is the headline result (p(A | B)). Below it the bayes' Theorem Calculator lists p(B), which describe the same case from other angles. IEEE-754 double precision; shown to at most 6 decimal places.
Why the answer is low
P(B) = 0.9 × 0.01 + 0.05 × 0.99 = 0.0585. The true positives are 0.009 of that, giving 0.009 ÷ 0.0585 = 15.4%. Because the condition is rare, most positives are false.
Base rates
Ignoring the prior (the base-rate fallacy) leads people to expect 90%. Out of 10,000 people, 100 have the condition (90 test positive) while 495 of the 9,900 healthy ones also test positive. The denominator must be positive.
How the result changes with prior P
Holding every other input at the first worked example, this table changes only prior P. It shows how sensitive the answer is to that one value; each row was produced by running this calculator.
| Prior P | P(A | B) | P(B) |
|---|---|---|
| 0.005 | 0.082949 | 0.05425 |
| 0.01 | 0.153846 | 0.0585 |
| 0.02 | 0.268657 | 0.067 |
| 0.04 | 0.428571 | 0.084 |
What happens with invalid input
These messages are produced by the calculator itself, so you know what to fix.
- Prior P(A): entering "0" shows "P(B) is zero, so the posterior is undefined." beside that field and no result.
Choosing between the Bayes' Theorem Calculator and similar calculators
Each row shows what a related calculator on this site asks for and what it returns, so you can pick the one that matches your question.
| Calculator | You enter | It returns |
|---|---|---|
| [Probability Calculator](/statistics/probability-calculator/) | p, p and events are | P(A and B) |
| [Dice Average Calculator](/statistics/dice-average/) | number of dice and sides per die | Average roll |
| [Permutation and Combination Calculator](/statistics/permutation-and-combination-calculator/) | total items and chosen items | Combinations (nCr) |
| [Expected Value Calculator](/statistics/expected-value/) | values and probabilities | Expected value E[X] |
| [Implied Probability Calculator](/statistics/implied-probability/) | odds format and odds | Implied probability |
Background: probability and distributions
A probability model only applies when its conditions hold. The binomial model needs a fixed number of independent trials with two outcomes and a constant success probability; its mass function gives the chance of exactly k successes. The normal density is f(x) = 1 ÷ (σ√(2π)) × e^(−(x − μ)² ÷ (2σ²)).
A cumulative probability adds up everything at or below a value, a density or mass function gives the value at a point. For a standard normal variable, z = −1.96 leaves 0.025 in the lower tail, which is why ±1.96 bounds a 95% interval.
Assumptions and limitations
- Denominator must be positive
If a required value is empty, not a number, or outside its allowed range, the form marks that field with a message and shows no result instead of a misleading number. The automated checks deliberately try invalid entries for prior P(A) to confirm this.
Frequently asked questions
What is the prior?
The probability before seeing evidence.
What happens at a 10% prior?
The posterior rises to about 66.7%.
What is sensitivity?
P(positive | condition).
What does the Bayes' Theorem Calculator calculate?
Posterior probability from a prior and test accuracy. It returns P(A | B) and P(B).
What formula does the Bayes' Theorem Calculator use?
P(A | B) = P(B|A)P(A) ÷ [P(B|A)P(A) + P(B|¬A)P(¬A)]. Law of total probability for the denominator.
What do I need to enter in the bayes' Theorem Calculator?
You enter Prior P(A), P(B | A) and P(B | not A).
How is the result rounded or limited?
IEEE-754 double precision; shown to at most 6 decimal places. Denominator must be positive.
What is an example of a bayes' Theorem result?
With prior P(A) 0.01, p(B | A) 0.9 and p(B | not A) 0.05, the p(A | B) is 0.153846.
Related calculators
- Probability Calculator — Probability of A and B, and A or B, for independent or mutually exclusive events.
- Dice Average Calculator — Average, minimum and maximum of rolling several dice.
- Permutation and Combination Calculator — Number of permutations and combinations of r items from n.
- Expected Value Calculator — Expected value and variance of a discrete distribution.
- Implied Probability Calculator — Probability implied by betting odds.
- Pythagorean Theorem Calculator — Find the hypotenuse or a missing leg of a right triangle.
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods (itl.nist.gov/div898/handbook)
- Standard textbook definitions (e.g. Moore, McCabe & Craig, Introduction to the Practice of Statistics)
Content last reviewed 2026-11-04. Formulas and worked examples are checked by automated tests against independently computed values.