Bayes Rule Calculator

Calculate a posterior probability from a prior and two event likelihoods, including the total evidence probability.

Enter P(A), P(B given A) and P(B given not A) as decimals from 0 to 1, with at most 12 decimal places.

Inputs are processed in this browser and are not uploaded.

Bayes Rule Calculator: supported calculation

Calculate a posterior probability from a prior and two event likelihoods, including the total evidence probability. Enter P(A), P(B given A) and P(B given not A) as decimals from 0 to 1, with at most 12 decimal places.

Enter the inputs

Fill the three labeled probability fields, then choose Calculate. Use a decimal such as 0.25 for 25%, not 25 or 25%. The example button replaces your inputs with the worked case below.

Worked example

A bag is selected from group A with probability 0.4. A red token has probability 0.75 in group A and 0.25 outside it. After observing red, P(A given red) = (0.4 × 0.75)/(0.4 × 0.75 + 0.6 × 0.25) = 2/3, approximately 0.666666666667. The evidence probability is 0.45.

Formula and assumptions

Bayes rule gives P(A given B) = P(A)P(B given A)/P(B). For the two exhaustive cases A and not A, P(B) = P(A)P(B given A) + (1 − P(A))P(B given not A). The second likelihood is essential; the first alone does not determine the posterior.

Unsupported cases and common mistakes

A zero evidence probability makes the posterior undefined and produces an error. Zero or one priors are permitted when the evidence has positive probability. This calculator combines the supplied probabilities; it does not verify their source, estimate likelihoods from observations or establish that the underlying model describes reality.

Limits and result precision

Decimal input is converted to fixed-point integers with 12 fractional places, so consistency checks and intermediate products do not depend on a floating-point tolerance. Final ratios are shown to 12 significant digits and may be rounded. This display precision does not make estimated input probabilities more accurate.

Editing any field clears the previous result. Calculate again after a change; Copy results includes the displayed labels and answers.

Use Conditional Probability Calculator to work directly from known marginals and an intersection.