Bayes’ Theorem Calculator — Prior, Likelihood & Posterior Probability
Update a hypothesis probability after observing evidence. Enter a prior and likelihood, then use either the evidence likelihood under the alternative hypothesis or the overall evidence probability.
Enter prior and evidence probabilities
Posterior result
Your updated probability will appear here. Enter probabilities and select Calculate posterior.
Bayes’ theorem formulas
Form
Formula
Use it when
Direct evidence
P(H | E) = P(E | H)P(H) / P(E)
The overall probability of the evidence P(E) is known.
H and not H exhaust the possibilities and both evidence likelihoods are known.
Odds form
Posterior odds = prior odds × likelihood ratio
You want to see how strongly the evidence changes the odds. For prior probability p, prior odds = p/(1-p), which is finite for 0 ≤ p < 1. LR = P(E | H) / P(E | not H) is finite when P(E | not H) > 0. When P(E) > 0 and posterior odds are finite, posterior probability = posterior odds/(1+posterior odds). In the worked example, prior odds are 1:99 and LR = 0.90/0.05 = 18, giving posterior odds 18:99 and posterior probability 18/(18+99), approximately 15.38%.
Terms: the prior P(H) is the probability before evidence E. The likelihood P(E | H) describes evidence assuming H. The posterior P(H | E) is the updated probability after observing E. A likelihood is not itself a probability that H is true.
How to interpret a Bayesian update
Evidence that supports H
For a prior strictly between 0 and 1 and evidence with P(E) > 0, the posterior is above the prior when E is more likely under H than under not H. When P(E | not H) > 0, this means the likelihood ratio is greater than 1; for a fixed prior, larger ratios produce larger posteriors. If P(E | not H) = 0 and P(E | H) > 0, the posterior is 1.
Evidence against H
For a prior strictly between 0 and 1 and evidence with P(E) > 0, the posterior falls when E is less likely under H than under not H, giving a likelihood ratio below 1. A ratio of exactly 1 leaves the prior unchanged. Boundary priors of 0 or 1 remain unchanged whenever conditioning is defined. If P(E) = 0, the posterior is undefined.
Assumptions and limits
The two-hypothesis form assumes H and not H are mutually exclusive and exhaustive.
Every input must refer to the same population, conditions, and definition of evidence.
Repeated updates require conditional likelihoods appropriate to all evidence already observed; multiplying as though dependent observations were independent can overstate certainty.
The numerical result inherits any bias or uncertainty in the prior and likelihood inputs.
Important: this is an educational probability calculator, not medical, legal, financial, or safety advice. P(E | not H) is the chance of observing E when H is false. When H means the condition is present and E means a positive test result, it is the false-positive rate, equal to 1 minus specificity, not 1 minus sensitivity. Use prevalence and performance values that match the relevant population and setting.
Worked Bayes’ theorem example
Using hypothetical teaching values, suppose a condition has a 1% prior probability, a test detects it 90% of the time when present, and the test is positive 5% of the time when it is absent. For the calculations below, 1% equals 0.01, 90% equals 0.90, and 5% equals 0.05.
Joint probability of the condition and a positive result: 0.90 × 0.01 = 0.009.
Total positive-result probability: P(E) = 0.009 + (0.05 × 0.99) = 0.0585, or 5.85%, by the law of total probability. In direct-evidence mode, use P(E) = 5.85% with the same prior and likelihood to obtain the same posterior as using P(E | not H) = 5% in the alternative-likelihood mode. The 5.85% is the overall positive-result rate; the 5% is the false-positive rate among cases without the condition.
Posterior probability: 0.009 / 0.0585 = 0.153846, or about 15.38%.
Among 10,000 hypothetical cases with these teaching values, 100 have the condition and 90 of those test positive. Of the remaining 9,900 cases without the condition, 495 test positive. Thus, 90 of the 585 positive results are cases with the condition: 90/585 is approximately 15.38%. The positive result raises the probability substantially, but the posterior is not 90%. The low prior and false positives among the larger condition-absent group matter.
Frequently asked questions
What is Bayes’ theorem?
Bayes’ theorem reverses a conditional probability: P(H | E) = P(E | H)P(H) / P(E), as long as P(E) is greater than zero.
What is a prior probability?
The prior P(H) describes how probable H is before accounting for the current evidence. It may come from a base rate, earlier data, or an explicitly stated model.
What is a likelihood?
The likelihood P(E | H) is the chance of observing E if H is true. It points in the opposite conditional direction from the posterior P(H | E), so the two should not be confused.
How is the evidence probability P(E) calculated?
When H and not H cover all possibilities, P(E) = P(E | H)P(H) + P(E | not H)P(not H). This is the law of total probability.
Can the posterior be lower than the prior?
Yes. For a prior strictly between 0 and 1 and P(E) > 0, the posterior is lower when the observed evidence is less likely under H than under not H. In odds terms, this means the likelihood ratio is below 1. Under the same conditions, evidence more likely under H raises the posterior. Boundary priors of 0 or 1 remain unchanged when conditioning is defined; if P(E) = 0, the posterior is undefined.
What makes a direct P(E) value mathematically valid?
Using probabilities on the 0 to 1 scale, P(E) must be greater than zero for the posterior to be defined. It must also be consistent with the prior and P(E | H): for a two-part partition, P(E | H)P(H) ≤ P(E) ≤ P(E | H)P(H) + P(not H). When P(H) < 1, these bounds keep the implied alternative likelihood [P(E) − P(E | H)P(H)] / P(not H) between 0 and 1. When P(H) = 1, consistency requires P(E) = P(E | H); the alternative likelihood cannot be recovered by dividing by P(not H), because that denominator is zero. These are mathematical constraints.
Does this calculator provide a diagnosis?
No. It only performs the probability update you specify. Real test interpretation also depends on how the population was selected, test thresholds, dependence, measurement error, and clinical context.
Are my inputs tracked?
No. The calculator runs in your browser and does not send, store, or attach entered probabilities to analytics events.