Bayesian Posterior Probability Estimator
Update a prior probability with observed evidence using Bayes' theorem: enter prior, likelihoods and successes to get the posterior probability and Bayes.
Bayesian Posterior Probability Estimator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser โ no data is sent to any server.
Formula: P(H|D) = P(D|H) x P(H) / [P(D|H) x P(H) + P(D|not H) x P(not H)]
Worked example โ Posterior probability of disease given a positive test: 8.76%. Despite the positive result, there is still a 91.24% chance of no disease.
Formula
P(H|D) = P(D|H) x P(H) / [P(D|H) x P(H) + P(D|not H) x P(not H)]
Where P(H|D) is the posterior probability of the hypothesis given data, P(D|H) is the likelihood of data given hypothesis, P(H) is the prior probability, and the denominator is the total probability of the data (marginal likelihood).
Worked Examples
Example 1: Medical Diagnostic Test
Problem:A disease has a 1% prevalence (prior = 0.01). A test has 95% sensitivity (likelihood if true = 0.95) and 10% false positive rate (likelihood if false = 0.10). One positive test observed out of 1 test.
Solution:P(D|disease) = C(1,1) x 0.95^1 x 0.05^0 = 0.95 P(D|no disease) = C(1,1) x 0.10^1 x 0.90^0 = 0.10 P(D) = 0.95 x 0.01 + 0.10 x 0.99 = 0.0095 + 0.099 = 0.1085 P(disease|positive) = 0.0095 / 0.1085 = 0.0876 = 8.76% Bayes Factor = 0.95 / 0.10 = 9.5 (substantial evidence on the Jeffreys scale, which puts 3 to 10 in that band)
Result:Posterior probability of disease given a positive test: 8.76%. Despite the positive result, there is still a 91.24% chance of no disease.
Example 2: A/B Test Conversion Rate
Problem:Prior belief that variant B is better: 50% (prior = 0.5). If B is better, likelihood of 7 out of 10 conversions = 0.85. If B is not better, likelihood = 0.35. Sample: 10 users, 7 converted.
Solution:P(D|B better) = C(10,7) x 0.85^7 x 0.15^3 = 120 x 0.320577 x 0.003375 = 0.12983 P(D|B not better) = C(10,7) x 0.35^7 x 0.65^3 = 120 x 0.00064339 x 0.274625 = 0.02120 P(D) = 0.12983 x 0.5 + 0.02120 x 0.5 = 0.07552 P(B better|D) = 0.06492 / 0.07552 = 86.0%
Result:Posterior probability that variant B is better: 86.0%. Bayes Factor: 6.12 (substantial evidence).
Frequently Asked Questions
What is a Bayesian posterior probability and how is it calculated?
A Bayesian posterior probability represents the updated belief about a hypothesis after observing new data. It is calculated using Bayes theorem, which combines the prior probability (your initial belief) with the likelihood of the observed data under the hypothesis. The formula is P(H|D) = P(D|H) x P(H) / P(D), where P(H|D) is the posterior, P(D|H) is the likelihood, P(H) is the prior, and P(D) is the marginal likelihood or evidence. This approach allows you to systematically update beliefs as new information becomes available, making it foundational in statistics, machine learning, and scientific reasoning.
What is the Bayes factor and how should I interpret it?
The Bayes factor quantifies the strength of evidence provided by observed data in favor of one hypothesis over another. It is the ratio of the likelihood of the data under the true hypothesis to the likelihood under the false hypothesis. A Bayes factor of 1 means the data equally supports both hypotheses. Values between 1 and 3 indicate weak evidence, 3 to 10 indicate substantial evidence, 10 to 30 indicate strong evidence, 30 to 100 indicate very strong evidence, and above 100 indicate decisive evidence. Unlike p-values, the Bayes factor directly compares hypotheses and does not depend on sample size alone.
How do I choose an appropriate prior probability for my analysis?
Choosing a prior depends on available background knowledge. Informative priors use existing research, expert opinion, or historical data to set an initial belief. For example, if previous studies show a treatment works 40 percent of the time, you might set the prior at 0.4. Uninformative or flat priors like 0.5 express ignorance and let the data dominate the posterior. Sensitivity analysis involves running the calculation with different priors to see how much the posterior changes. If the posterior is robust across reasonable priors, your conclusion is more reliable. In practice, the more data you have the less the prior matters.
What is the difference between Bayesian and frequentist statistics?
Bayesian statistics treats probability as a degree of belief that gets updated with evidence, while frequentist statistics treats probability as the long-run frequency of events. In frequentist inference, a parameter is fixed and unknown, and you use p-values and confidence intervals. In Bayesian inference, parameters have probability distributions that represent uncertainty. Bayesian methods incorporate prior knowledge, produce intuitive probability statements about hypotheses, and naturally handle small sample sizes. Frequentist methods do not require priors, are computationally simpler for many problems, and have well-established regulatory acceptance in fields like clinical trials.
Can Bayesian posterior estimation be used in machine learning applications?
Bayesian posterior estimation is widely used in machine learning for tasks like classification, regression, model selection, and hyperparameter tuning. Naive Bayes classifiers use posterior probabilities to assign categories to data points. Bayesian optimization uses posterior distributions over objective functions to efficiently search hyperparameter spaces. Bayesian neural networks place distributions over weights to capture model uncertainty, which is critical in safety-sensitive applications like autonomous driving and medical diagnosis. Gaussian processes are another Bayesian approach providing uncertainty-aware predictions. The main challenge is computational cost, often addressed through variational inference or Markov Chain Monte Carlo sampling methods.
How do prior odds, the Bayes factor and posterior odds fit together?
Bayes theorem is at its cleanest in odds form: posterior odds equal prior odds multiplied by the Bayes factor. A prior of 0.3 is odds of 0.3/0.7 = 0.4286, so a Bayes factor of 6 produces posterior odds of 2.571, which converts back to a probability of 2.571/3.571, or about 72 percent. That multiplicative structure is also why evidence accumulates so tidily: independent batches of data multiply their Bayes factors, or equivalently add their logarithms, and the order of arrival makes no difference.
Why does a positive result on a highly sensitive test often still mean no disease?
Because the prior dominates whenever a condition is rare. Take 10,000 people at 1 percent prevalence: 100 actually have it and a 95 percent sensitive test catches 95 of them, while 9,900 are healthy and a 10 percent false positive rate generates 990 positives. Of the 1,085 positive results only 95 are genuine, roughly 8.8 percent. This is base rate neglect, and it explains why screening an asymptomatic population demands far higher specificity than testing people who already show symptoms.
Why does the binomial coefficient cancel out of the Bayes factor?
The likelihood of k successes in n trials is C(n,k) times p to the k times (1 - p) to the (n - k), and that combinatorial term counts orderings which are identical whichever hypothesis holds. It therefore appears unchanged in the numerator and the denominator, cancelling out of the Bayes factor and out of the posterior as well. Only the two success probabilities and the observed counts move the answer. The coefficient still scales the marginal likelihood P(D), which is why that number alone says nothing about which hypothesis is winning.
What changes if I put a Beta prior over the success rate instead of comparing two fixed values?
Bayesian Posterior Probability Estimator weighs two specific point hypotheses against each other. The common alternative treats the success rate itself as unknown and assigns it a Beta(alpha, beta) prior, which is conjugate to the binomial likelihood: after k successes in n trials the posterior is simply Beta(alpha + k, beta + n - k). That gives a whole distribution rather than one probability, so a credible interval can be read straight off it. Use the point comparison when two concrete rival rates are genuinely at stake, and the Beta form when the rate is what you want to estimate.
What happens if I set the prior or a likelihood to exactly 0 or 1?
The update collapses. A prior of 0 multiplies away every subsequent piece of evidence, so no quantity of data can lift the posterior above zero, and a prior of 1 is equally immovable. That is the point behind Cromwell's rule, which urges analysts to leave a sliver of probability for being wrong. Setting a likelihood to 0 is just as absolute: an outcome declared impossible under a hypothesis eliminates that hypothesis the instant it is observed. Keep values near the limits rather than on them.
References
Background & Theory
History
Reviewed for accuracy by Daniel Agrici, Founder & Lead Developer ยท Editorial policy
Related Calculators
๐งฎ3D Print Time Support Estimator
Calculate 3d print time support estimator with inputs, formulas, and instant results.
๐งฎBackup Restore Time Estimator
Calculate backup restore time estimator with inputs, formulas, and instant results.
๐งฎCar Rental Total Cost Estimator
Calculate car rental total cost estimator with inputs, formulas, and instant results.
๐งฎCDN Caching Benefit Estimator
Calculate cdn caching benefit estimator with inputs, formulas, and instant results.
๐งฎCloud Cost Estimator Heuristic
Calculate cloud cost estimator heuristic with inputs, formulas, and instant results.
๐งฎCustoms Duty Estimator Heuristic
Calculate customs duty estimator heuristic with inputs, formulas, and instant results.
๐งฎData Compression Savings Estimator
Calculate data compression savings estimator with inputs, formulas, and instant results.
๐งฎDraft Pick Value Estimator
Calculate draft pick value estimator with inputs, formulas, and instant results.