Calculate Bayesian Posterior Probability P(A|B)

Enter prior probability P(A), likelihood P(B|A), and false positive likelihood P(B|A').

Prior belief $P(A)$ (e.g. 0.01 = 1% prevalence).
True positive rate $P(B|A)$ (e.g. 0.95 = 95%).
False positive rate $P(B|A')$ (e.g. 0.05 = 5%).

Calculation Results

Primary Metric Output --
Metric Breakdown 1--
Metric Breakdown 2--
Metric Breakdown 3--
Metric Breakdown 4--
Metric Breakdown 5--
Mathematical Standard--

Calculated using Bayes\' Theorem equations: P(A|B) = \frac{P(B|A) P(A)}{P(B|A) P(A) + P(B|A\') P(A\')}

*Note: Bayes\' Theorem updates the prior probability P(A) of a hypothesis upon observing new evidence B.

Quick Summary

The Bayes Theorem Calculator evaluates posterior probability $P(A|B) = \frac{P(B|A) P(A)}{P(B)}$, total evidence $P(B)$, and Bayes Factor.

Formula Explanation

P(A|B) = \frac{P(B|A) \cdot P(A)}{P(B)}
P(B) = P(B|A) \cdot P(A) + P(B|A') \cdot P(A')

How It Works

Bayes' Theorem provides a mathematical framework for updating probabilities when new evidence is discovered. The Bayes Theorem Calculator combines prior probability $P(A)$, true positive likelihood $P(B|A)$, and false positive rate $P(B|A')$ to calculate posterior probability $P(A|B)$.

Step-by-Step Worked Example

Practical Problem: A rare disease has prior prevalence $P(A) = 0.01$ (1%). A medical screening test has 95% sensitivity ($P(B|A) = 0.95$) and a 5% false positive rate ($P(B|A') = 0.05$). Calculate probability a patient has the disease given a positive test ($P(A|B)$).

  1. Step 1: Calculate complement prior $P(A')$: $P(A') = 1 - 0.01 = \mathbf{0.99}$.
  2. Step 2: Calculate true positive joint probability: $P(B|A) \cdot P(A) = 0.95 \times 0.01 = \mathbf{0.0095}$.
  3. Step 3: Calculate false positive joint probability: $P(B|A') \cdot P(A') = 0.05 \times 0.99 = \mathbf{0.0495}$.
  4. Step 4: Calculate total evidence $P(B)$: $P(B) = 0.0095 + 0.0495 = \mathbf{0.0590\text{ (5.90\% test positive rate)}}$.
  5. Step 5: Calculate Posterior Probability $P(A|B)$: $P(A|B) = 0.0095 / 0.0590 = \mathbf{0.161017\text{ (16.10\%)}}.$

Real-World Calculation Examples

Scenario 1: Medical Rare Disease Screening

Parameters: P(A) = 1%, Sensitivity = 95%, False Pos = 5%
Result: P(A|B) = 16.10% Positive Predictive Value (PPV).

Scenario 2: Email Spam Filter Classification

Parameters: Prior Spam P(S) = 20%, Word "Free" in Spam = 80%, in Non-Spam = 10%
Result: P(Spam|"Free") = 66.67%.

Scenario 3: Financial Credit Fraud Detection

Parameters: Fraud P(F) = 0.1%, Alarm | Fraud = 99%, False Alarm = 1%
Result: P(Fraud|Alarm) = 9.01%.

Scenario 4: High Prevalence Disease (COVID Trial)

Parameters: Prior P(A) = 20%, Sensitivity = 90%, False Pos = 5%
Result: P(A|B) = 81.82% PPV.

Key Benefits of Using This Calculator

Base Rate Fallacy Prevention

Demonstrates how low prior prevalence reduces positive predictive value (PPV).

Total Evidence $P(B)$ Output

Displays total evidence probability denominator $P(B)$.

Bayes Factor Assessment

Calculates Bayes Factor ratio $\frac{P(B|A)}{P(B|A')}$ to quantify evidence strength.

100% Free & Client-Side

Executes locally in your browser with zero latency or web server transmission.

Frequently Asked Questions (FAQ)

What is Bayes' Theorem?

Bayes' Theorem is a mathematical formula that calculates updated (posterior) probability of a hypothesis given new evidence.

What is the Base Rate Fallacy?

The Base Rate Fallacy occurs when people ignore low prior probability $P(A)$, overestimating positive test accuracy.

What is Positive Predictive Value (PPV)?

PPV is the posterior probability $P(\text{Disease} \mid \text{Positive Test})$ calculated via Bayes' Theorem.

What is prior probability $P(A)$ vs posterior probability $P(A|B)$?

Prior $P(A)$ is belief before seeing evidence; posterior $P(A|B)$ is updated belief after observing evidence $B$.

How is Bayes' Theorem used in Machine Learning (Naïve Bayes)?

Naïve Bayes classifiers apply Bayes' Theorem with feature independence assumptions for text classification and spam filtering.

What is Bayes Factor?

Bayes factor is the ratio of likelihoods $\frac{P(B|A)}{P(B|A')}$, measuring the relative strength of evidence.

How do I calculate Bayes' Theorem in Excel?

Use formula =(pBA * pA) / ((pBA * pA) + (pBNotA * (1 - pA))).

Who was Thomas Bayes?

Reverend Thomas Bayes was an 18th-century English statistician and Presbyterian minister who formulated Bayes' Theorem.

What is Bayesian inference vs Frequentist inference?

Frequentists view probability as long-run frequency; Bayesians treat probability as a measure of belief updated by data.

Can prior probability P(A) be updated multiple times?

Yes — sequential Bayesian updating uses current posterior probability as the new prior for subsequent evidence.