Bayesian Probability Calculator
Why use a Bayesian probability calculator?
Bayes’ theorem is a standard way to update a belief (a hypothesis) after you observe some new evidence. Instead of treating probability as fixed, Bayesian updating treats it as something you revise as information arrives. This is useful in everyday “is it true?” questions (spam filtering, A/B testing, fraud detection) and in high-stakes settings (medical testing, quality control, risk assessment).
This calculator implements the classic binary form of Bayes’ theorem: a hypothesis is either true (H) or not true (¬H), and the evidence E is either observed (for example, a “positive” test) or not. You provide three inputs—the prior probability of the hypothesis, the likelihood of the evidence if the hypothesis is true, and the likelihood of the evidence if the hypothesis is false—and the calculator returns the posterior probability of the hypothesis after seeing the evidence.
What the inputs mean (plain language)
- Prior Probability =
P(H): your belief that the hypothesis is true before seeing the evidence. In medical testing this is often the prevalence or base rate. - Likelihood if True =
P(E|H): the chance of observing the evidence if the hypothesis is true. In diagnostic testing, when E is “test is positive,” this is the sensitivity / true positive rate. - Likelihood if False =
P(E|¬H): the chance of observing the evidence even though the hypothesis is false. In diagnostic testing, this is the false positive rate, which equals1 − specificity.
Tip: Many users accidentally enter specificity into “Likelihood if False.” If you have specificity instead, convert it first: false positive rate = 100% − specificity.
The formula (Bayes’ theorem)
In symbols, the posterior probability is:
Where P(¬H) = 1 − P(H). The denominator is a “normalizing” term that makes sure the result is between 0 and 1. It is also the overall probability of seeing the evidence:
P(E) = P(E|H)P(H) + P(E|¬H)P(¬H)
Interpreting the result
The output P(H|E) is the probability that the hypothesis is true given that you observed the evidence. If the result is higher than your prior, the evidence supports the hypothesis. If it’s lower than your prior, the evidence argues against it.
Two common interpretation pitfalls:
- Confusing
P(H|E)withP(E|H). Sensitivity/likelihood is not the same as the posterior probability. - Ignoring the base rate (the prior). Rare conditions can still have low posterior probability even with a “good” test if false positives are non-trivial.
Worked example (medical test)
Suppose a disease affects 1% of the population. A test returns positive 95% of the time when the disease is present, and returns positive 10% of the time when the disease is absent.
- Prior:
P(H) = 0.01 - Likelihood if true (sensitivity):
P(E|H) = 0.95 - Likelihood if false (false positive rate):
P(E|¬H) = 0.10
Compute:
P(H|E) = (0.95×0.01) / (0.95×0.01 + 0.10×0.99) ≈ 0.0876
So even after a positive test, the chance the patient truly has the disease is about 8.8%. The test is fairly sensitive, but the disease is rare and false positives accumulate among the many healthy people.
Quick comparison table (how inputs affect the posterior)
| Scenario | Prior P(H) | P(E|H) | P(E|¬H) | Posterior P(H|E) | What changed? |
|---|---|---|---|---|---|
| Baseline example | 1% | 95% | 10% | ≈ 8.8% | Rare condition limits posterior |
| Higher prior | 10% | 95% | 10% | ≈ 51.3% | More plausible upfront → higher posterior |
| Lower false positives | 1% | 95% | 1% | ≈ 49.0% | Better specificity (lower FPR) boosts posterior |
| Weaker evidence | 1% | 60% | 10% | ≈ 5.7% | Evidence less diagnostic |
Assumptions and limitations
- Binary framing: This version assumes a yes/no hypothesis (H vs ¬H) and a single observed piece of evidence (E vs not E). Multi-class hypotheses or multiple evidence items require extensions.
- Correct direction of conditionals: Inputs must be
P(E|H)andP(E|¬H), notP(H|E). Mixing these up yields misleading results. - Base-rate dependence: When the prior is very small, even strong evidence may not produce a large posterior unless the false-positive rate is extremely low.
- Evidence definition matters: “Evidence” should be defined consistently. For a test, E often means “test is positive.” If you want to handle a negative test, you’d use
P(not E|H)andP(not E|¬H)instead. - Edge cases: If
P(E)becomes 0 (for example, both likelihoods are 0), the posterior is undefined because the evidence is impossible under both scenarios. If you enter 0% or 100% for priors/likelihoods, you are making absolute claims that can force posteriors to 0 or 100. - Independence across multiple updates: If you plan to update repeatedly with multiple pieces of evidence, you must ensure you are not double-counting correlated evidence (a common real-world issue).
Reference note
Bayes’ theorem is a standard identity in probability theory relating conditional probabilities: P(H|E) and P(E|H). Terminology like sensitivity/specificity is common in diagnostic testing and maps directly to the likelihood inputs above.
Mini-Game: Signal Sweep
Steer the decision lens to catch evidence cards with strong likelihood ratios and dodge noisy traps. Keep your posterior climbing through shifting uncertainty waves.
Tip: higher P(E|H) than P(E|¬H) means the card supports H. Catch those to improve posterior odds.
