Skip to content
CalculatorAtlas

Bayes' Theorem Calculator

Tested

Posterior probability from a prior and test accuracy.

Tested, not yet published. The formula for this calculator is implemented and passes its automated checks. This page stays non-indexable until it is reviewed and published.

Results

Enter your values and press Calculate. Results appear here.

  • • Result

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

  1. Enter prior P(A) (between 0 and 1).
  2. Enter p(B | A) (between 0 and 1).
  3. Enter p(B | not A) (between 0 and 1).
  4. Press Calculate to see the result, and use Reset to start again.
Inputs of the Bayes' Theorem Calculator
InputWhat to enterAllowed 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.

Results of example 1
ResultValue
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.

How the result changes with prior P
Prior PP(A | B)P(B)
0.0050.0829490.05425
0.010.1538460.0585
0.020.2686570.067
0.040.4285710.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.

Choosing between the Bayes' Theorem Calculator and similar calculators
CalculatorYou enterIt returns
[Probability Calculator](/statistics/probability-calculator/)p, p and events areP(A and B)
[Dice Average Calculator](/statistics/dice-average/)number of dice and sides per dieAverage roll
[Permutation and Combination Calculator](/statistics/permutation-and-combination-calculator/)total items and chosen itemsCombinations (nCr)
[Expected Value Calculator](/statistics/expected-value/)values and probabilitiesExpected value E[X]
[Implied Probability Calculator](/statistics/implied-probability/)odds format and oddsImplied 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.

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.