Bayes' Theorem Calculator
Print PageBayes’ Theorem (also known as Bayesian Conditional Probability Rule, Inverse Probability Formula, Prior-to-Posterior Updating Rule, or Bayes’ Law) is a foundational theorem in probability theory and statistics that calculates the revised posterior probability of an event A occurring given that evidence or event B has already occurred (P(A|B) = [P(B|A) · P(A)] ÷ P(B), where P(A) is the initial prior probability of A, P(B|A) is the likelihood of observing evidence B given A, and P(B) is the total probability of evidence B). Across medical diagnostic screening (resolving the Base Rate Fallacy in rare disease testing), email spam filtering algorithms (Naive Bayes classifiers), financial credit risk default forecasting, legal courtroom evidence evaluation, and machine learning artificial intelligence, Bayes’ Theorem provides the exact mathematical framework for updating beliefs in light of new empirical data.
Our free online Bayes’ Theorem Calculator provides instant, high-precision calculations for conditional probability, medical screening diagnostic accuracy, and Bayesian inference:
- Bayes’ Fundamental Formula [Standard Conditional Probability]:
P(A|B) = [ P(B|A) · P(A) ] ÷ P(B). - Expanded Law of Total Probability [Binary Test Standard]:
P(A|B) = [ P(B|A) · P(A) ] ÷ [ P(B|A) · P(A) + P(B|Ac) · (1 - P(A)) ](whereP(B|Ac)is the False Positive Rate). - Medical Diagnostic Test Sensitivity & Specificity:
Positive Predictive Value (PPV) = (Sensitivity · Prevalence) ÷ [ (Sensitivity · Prevalence) + ( (1 - Specificity) · (1 - Prevalence) ) ].
Master Bayes’ Theorem Formula & Terminology Summary
The table below displays exact mathematical formulas, probability notation, and definitions used to calculate Bayesian posterior probabilities, likelihood ratios, and evidence totals:
| Bayesian Metric Name | Probability Symbol | Mathematical Formula | Technical Application & Clinical Meaning |
|---|---|---|---|
| Posterior Probability | P(A|B) |
[ P(B|A) · P(A) ] ÷ P(B) |
Updated probability of event A after observing new evidence B (PPV) |
| Prior Probability | P(A) |
Base Rate / Prevalence Rate | Initial background probability of event A before seeing evidence B |
| Likelihood (Sensitivity) | P(B|A) |
True Positive Rate (TPR) | Probability that evidence B is observed given event A is true |
| False Positive Rate | P(B|Ac) |
1 - Specificity |
Probability that evidence B is observed when event A is FALSE |
| Total Marginal Evidence | P(B) |
P(B|A)·P(A) + P(B|Ac)·P(Ac) |
Overall probability of evidence B occurring across all possibilities |
Step-by-Step Medical Disease Screening & Base Rate Fallacy Calculation Example
To calculate the true probability that a patient has a rare disease (event D) given a positive screening test result (event T+), where the disease prevalence is 1.0% (P(D) = 0.01), the test sensitivity is 99.0% (P(T+|D) = 0.99), and the test specificity is 95.0% (P(T–|Dc) = 0.95 ⇒ False Positive Rate P(T+|Dc) = 1 – 0.95 = 0.05):
Step 1 (Identify Priors & Likelihoods): P(D) = 0.01; P(Dc) = 1 - 0.01 = 0.99; P(T+|D) = 0.99; P(T+|Dc) = 0.05
Step 2 (Calculate True Positives Component): P(T+|D) · P(D) = 0.99 × 0.01 = 0.0099 (0.99% of total population)
Step 3 (Calculate False Positives Component): P(T+|Dc) · P(Dc) = 0.05 × 0.99 = 0.0495 (4.95% of total population)
Step 4 (Calculate Total Positive Test Probability P(T+)): P(T+) = 0.0099 + 0.0495 = 0.0594 (5.94% of total population)
Step 5 (Apply Bayes' Formula for Posterior P(D|T+)): P(D|T+) = 0.0099 ÷ 0.0594 = 0.166667 = 16.67%
Thus, despite receiving a 99% sensitive test that comes back positive, the patient only has a 16.67% actual chance of having the disease due to the strong counterweight of the 1% background base rate (the classic Base Rate Fallacy).
Real-World Medical, Spam Classifier & Industrial Benchmarks
Below is a comparative reference chart showing prior probabilities, likelihoods, false positive rates, and updated posterior probabilities across healthcare, artificial intelligence, and defect inspection:
| Probability Application / Real-World Scenario | Prior P(A) & Likelihood P(B|A) | False Positive Rate P(B|Ac) | Updated Posterior Probability P(A|B) |
|---|---|---|---|
| Rare Disease Mammogram Screening (Base Rate Fallacy) | P(D) = 1.0%, Sensitivity = 99.0% | 5.0% (Specificity = 95.0%) | 16.67% (PPV given positive test result) |
| Naive Bayes Email Spam Filter (“FREE” Keyword) | P(Spam) = 30.0%, P(“FREE”|Spam) = 80.0% | 5.0% (P(“FREE”|Ham)) | 87.27% (Probability email is spam if “FREE” present) |
| Automated Assembly Line Defect Sensor Alarm | P(Defect) = 2.0%, Sensor Accuracy = 98.0% | 3.0% (False alarm rate) | 40.00% (Probability part is defective given sensor alarm) |
| Financial Credit Card Fraud Transaction Detection | P(Fraud) = 0.5%, Flag Rate = 95.0% | 1.0% (False fraud alert) | 32.32% (Probability flagged charge is actual fraud) |
History & Mathematics: 1763 Reverend Thomas Bayes vs 1774 Pierre-Simon Laplace
1763 Reverend Thomas Bayes & Richard Price Royal Society Essay
Formulated by 18th-century English statistician and Presbyterian minister Reverend Thomas Bayes, the theorem was presented posthumously to the Royal Society of London in 1763 by his friend Richard Price in the seminal paper An Essay towards solving a Problem in the Doctrine of Chances. Bayes solved the “inverse probability” problem: inferring the underlying cause or parameter of an event based on observed frequency data.
1774 Pierre-Simon Laplace & Generalization of Inverse Probability
Independently of Bayes, French polymath Pierre-Simon Laplace derived the general formulation of Bayes’ Theorem in 1774 in his Mémoire sur la probabilité des causes par les événements. Laplace developed the mathematical foundation of Bayesian inference, applying it to astronomy, celestial mechanics, law, and population demographics, laying the groundwork for modern Bayesian statistics.
Popular direct tools:
Frequently Asked Questions (FAQ)
What is Bayes’ Theorem in simple terms?
Bayes’ Theorem is a mathematical formula that updates the probability of a hypothesis (event A) when new evidence (event B) is discovered: Posterior = (Likelihood · Prior) ÷ Total Evidence.
What is the Base Rate Fallacy?
The Base Rate Fallacy occurs when people ignore the low background prior probability (prevalence) of an event, focusing only on high test accuracy. For example, a 99% accurate test for a 1-in-1,000 disease will yield far more false positives than true positives, resulting in a low overall positive predictive value.
How is Bayes’ Theorem used in Machine Learning?
In Machine Learning, Naive Bayes classifiers use Bayes’ Theorem to predict probabilities of text categories (e.g., classifying emails as spam or ham, or sentiment analysis) assuming feature independence.
What is the difference between Sensitivity and Specificity in Bayes’ Theorem?
Sensitivity is the True Positive Rate P(B|A) (the chance a test detects a disease when present). Specificity is the True Negative Rate P(Bc|Ac) (the chance a test comes back negative when no disease is present). The False Positive Rate is 1 - Specificity.