CalcWorldHub
Probability · CalcWorldHub

Bayes’ Theorem for Two Hypotheses: Update a Probability

Bayes’ theorem turns a prior probability into a posterior after evidence is observed. If P(H)=0.01, P(E|H)=0.95, and P(E|not H)=0.05, then P(H|E)=0.0095/(0.0095+0.0495)≈16.10%. A high evidence likelihood does not erase a low prior.

Open calculator
Two hypothesis paths contribute prior-weighted likelihoods to a normalized posterior.

Share this article

Posterior probability is the hypothesis likelihood times the prior divided by total evidence probability.
The denominator includes evidence under both exhaustive hypotheses.

Name the hypotheses and evidence

The calculator uses Prior P(H), Evidence likelihood P(E|H), and P(E|not H). H is the hypothesis of interest, and not H is its alternative. The two hypotheses should be mutually exclusive and collectively exhaustive, and the likelihoods must describe the same observed evidence under each case.

All inputs are probabilities from 0 to 1, not percentages from 0 to 100. The prior P(H) is assigned before considering E; P(E|H) is not the same as P(H|E). Reversing those conditional probabilities is a common error and can change the result dramatically when H is rare.

Apply Bayes’ theorem

The posterior is P(H|E) = P(E|H)P(H) / [P(E|H)P(H) + P(E|not H)(1−P(H))]. The denominator is the total probability of the evidence across the two hypotheses. The numerator is the joint probability of H and E; dividing by the evidence probability conditions on having observed E.

For prior 0.01, sensitivity-like likelihood 0.95, and alternative likelihood 0.05, the numerator is 0.0095 and the denominator is 0.0095+0.0495=0.059. The posterior is about 0.1610. The evidence favors H, yet the posterior is far below 95% because the alternative hypothesis was much more common beforehand.

Worked examples

Rare hypothesis with positive evidence

Inputs: P(H)=0.01; P(E|H)=0.95; P(E|not H)=0.05

Calculation: 0.95×0.01 / [(0.95×0.01)+(0.05×0.99)] = 0.0095/0.059

Posterior P(H|E) ≈ 0.161017, or 16.10%.

Evidence favors a one-in-five prior

Inputs: P(H)=0.20; P(E|H)=0.80; P(E|not H)=0.10

Calculation: 0.80×0.20 / [(0.80×0.20)+(0.10×0.80)] = 0.16/0.24

Posterior P(H|E) = 2/3 ≈ 66.67%.

Prior probability and evidence likelihoods form weighted evidence terms that normalize to a posterior.
Both hypotheses contribute to the evidence denominator.

Interpret likelihood ratios and base rates

When both likelihoods are positive, the evidence likelihood ratio P(E|H)/P(E|not H) describes how much more compatible E is with H than with its alternative. The prior odds are then multiplied by that ratio to obtain posterior odds. A likelihood ratio above one favors H; below one favors not H.

This odds view helps diagnose base-rate neglect. A test can detect evidence reliably while still producing many false alarms in a population where H is rare. The calculator returns a posterior probability, but it does not estimate the prior or validate the likelihood model. Those inputs must come from a relevant study, process, or explicit assumption.

In the first example the evidence likelihood ratio is 0.95/0.05 = 19 in favor of H. Prior odds are 0.01/0.99 ≈ 0.01010; multiplying by 19 gives posterior odds about 0.1919, which convert to probability 0.1919/(1+0.1919) ≈ 0.1610. This odds check independently matches the direct Bayes calculation.

Check evidence and boundary cases

The calculator rejects probabilities outside 0…1 and displays an error when the evidence denominator is zero. It formats the posterior to nine decimal places. If P(E|H)=P(E|not H), the evidence has equal likelihood under both hypotheses and the posterior equals the prior. If P(E|not H)=0 while P(E|H)>0 and the prior is positive, observing E makes the posterior one under this two-hypothesis model.

A posterior of zero or one can follow from exact boundary inputs, but real measurements may not justify literal certainty. Rounded or sparse data can also make a likelihood zero even when the event is possible. Preserve the unrounded probability estimates where available, and check how the model handles such boundaries before making a consequential decision.

Use a defensible probability update

Before calculating, write down what H means, the time and population to which the prior applies, and the exact evidence event E. Source P(H) from information available before E, and estimate both conditional likelihoods from data relevant to the same setting. Mixing a prior from one population with likelihoods from another weakens the interpretation.

After the update, test sensitivity by varying uncertain inputs over plausible ranges. In the example, changing the prior can move the posterior substantially even though the evidence likelihood ratio stays fixed. Bayes’ rule is mathematically exact for its inputs; it cannot compensate for selection bias, missing hypotheses, poorly calibrated likelihoods, or dependent evidence entered as if it were one event.

Sources and further reading

Share this article

Browse all articles · Calculator: Bayes theorem calculator for two hypotheses