Compute the posterior probability P(A|B) from prior P(A), likelihood P(B|A), and false positive rate P(B|¬A). Visualize the update through an interactive probability tree and bar chart. Perfect for students, data scientists, medical professionals, and anyone learning Bayesian reasoning.
Bayes' Theorem (also known as Bayes' Rule or Bayes' Law) is a fundamental result in probability theory that describes how to update the probability of a hypothesis as new evidence becomes available. Named after the Reverend Thomas Bayes (1701–1761), whose posthumously published work laid the foundation, the theorem was later generalized and popularized by Pierre-Simon Laplace. Today, Bayes' Theorem is the engine behind modern Bayesian inference, used in everything from medical diagnostics and spam filtering to machine learning, finance, and scientific discovery.
Where:
P(A|B) = Posterior — probability of hypothesis A after seeing evidence B
P(A) = Prior — initial probability of A before evidence
P(B|A) = Likelihood — probability of evidence B given A is true
P(B|¬A) = False Positive Rate — probability of evidence B given A is false
P(¬A) = 1 − P(A) — probability that A is false
One of the greatest contributions of Bayes' Theorem is that it provides a formal, quantitative framework for reasoning under uncertainty. It forces us to be explicit about our assumptions (the prior) and the reliability of our evidence (the likelihood), and it shows exactly how evidence should shift our beliefs. This is in stark contrast to informal reasoning, which often suffers from base-rate neglect — the common cognitive bias where people ignore the overall frequency of an event when evaluating specific evidence.
Consider a screening test for a rare disease that affects 1 in 10,000 people (P(A) = 0.0001). The test has 99% sensitivity (P(B|A) = 0.99) and 99% specificity, meaning a 1% false positive rate (P(B|¬A) = 0.01). If a patient tests positive, what is the probability they actually have the disease?
Using Bayes' Theorem: P(A|B) = (0.99 × 0.0001) / (0.99 × 0.0001 + 0.01 × 0.9999) ≈ 0.98%. That is, a positive test result implies only about a 1% chance of actually having the disease — far lower than most people would guess. This is the base-rate fallacy in action: the rarity of the disease (the prior) dominates the calculation. Our calculator lets you explore this and similar scenarios interactively, building a robust intuition for Bayesian reasoning.
Key insight: Always consider the base rate. A highly accurate test can still produce many false positives when the condition is rare.
Bayesian methods are used to update scientific beliefs as new experimental data arrives. They provide a principled way to combine prior knowledge with new evidence, and are central to modern meta-analysis and clinical trial design.
Naive Bayes classifiers, Bayesian networks, and Gaussian processes are all built on Bayes' Theorem. They power spam filters, recommendation systems, and autonomous decision-making under uncertainty.
Bayesian updating is used in portfolio optimization, credit scoring, and fraud detection. It allows financial institutions to continuously refine risk assessments as new market data emerges.
Bayesian reasoning is increasingly used in legal contexts to evaluate forensic evidence, assess the probative value of DNA matches, and guide jury decision-making under uncertainty.
Our calculator implements the full Bayesian update in four transparent steps:
Additionally, we compute the Bayes Factor (BF = P(B|A) / P(B|¬A)), which quantifies how much the evidence shifts the odds in favor of A. A Bayes Factor > 1 supports A, while < 1 supports ¬A. We also show the prior odds (P(A)/P(¬A)) and posterior odds (P(A|B)/P(¬A|B)), which are related by the simple multiplicative formula: Posterior Odds = Bayes Factor × Prior Odds.
The interactive visualization on the right side of the result panel shows a probability tree that branches on A/¬A and then on B/¬B, with branch widths proportional to probabilities. The bar chart below compares prior and posterior probabilities, making the Bayesian update visually immediate.
Thomas Bayes' original essay, "An Essay towards solving a Problem in the Doctrine of Chances," was published posthumously in 1763. It addressed the inverse probability problem: given the outcomes of a series of trials, what can we infer about the underlying probability? Pierre-Simon Laplace independently developed similar ideas and applied them to astronomy, demography, and jurisprudence. In the 20th century, Bayes' Theorem became the foundation of the Bayesian school of statistics, which contrasts with the frequentist school that interprets probability as long-run frequency. Today, the two approaches are often complementary, and Bayesian methods are ubiquitous in modern data science.
Suppose 20% of all emails are spam (P(A) = 0.20). The word "free" appears in 90% of spam emails (P(B|A) = 0.90), but only in 10% of legitimate emails (P(B|¬A) = 0.10). If an email contains the word "free", what is the probability it is spam?
Calculation:
P(¬A) = 0.80
P(A ∩ B) = 0.90 × 0.20 = 0.18
P(¬A ∩ B) = 0.10 × 0.80 = 0.08
P(B) = 0.18 + 0.08 = 0.26
P(A|B) = 0.18 / 0.26 ≈ 0.6923 (69.2%)
So the presence of "free" increases the probability of spam from 20% to about 69%. This is why spam filters use multiple keywords and other features — each piece of evidence updates the posterior, and the combined effect can be very powerful.