Calculat.dev LogoCalculat.dev - All Calculators, One Place.devAll Calculators, One Place.
Probability CalculatorsPopular Tool Runs Locally

Bayes' Theorem Calculator

Calculate conditional posterior probability P(A|B), positive predictive value (PPV), false positives, and medical test accuracy.

e.g. 0.01 = 1% prevalence

True positive detection rate

1 - Specificity

Posterior Probability P(A|B) [Positive Predictive Value]
16.10%

If you test positive, the probability you genuinely have condition A is 16.1%.

10,000 Person Population Breakdown

True Positives
95
False Positives
495
False Negatives
5
True Negatives
9405
🎓

Did this calculation save you time?

Student Project

Hi! I'm a student developer building Calculat in my spare time. I was tired of searching for basic math tools and having to click through 10 spammy popups, loan ads, and cookie trackers.

I keep this website 100% free, private, and ad-free. If this helped you with your homework, project, or finances today, bookmarking this page or telling a friend helps me keep building more free tools!

Press ⌘ + D to Bookmark
Suggest What I Build Next

What Is a Bayes' Theorem Calculator?

Bayes' Theorem is a foundational mathematical formula that updates the probability of a hypothesis (prior probability) as new evidence or test results become available. It is widely applied in medical diagnostic testing, spam filtering algorithms, and machine learning.

How to Use This Calculator

  1. Enter the Prior Probability P(A) (e.g. disease prevalence in the general population).
  2. Enter the Sensitivity P(B|A) (True Positive rate; probability the test is positive if condition is present).
  3. Enter the False Positive Rate P(B|A') (probability the test is positive if condition is absent; equal to 1 - Specificity).
  4. Review the calculated Posterior Probability P(A|B) and the 10,000-person population contingency matrix.

Bayes' Theorem Formula

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

Where P(A|B) is the posterior probability of A given evidence B, P(B|A) is the likelihood/sensitivity, P(A) is the prior probability, and P(B) is the total marginal probability of observing evidence B.

Worked Example

Scenario: A rare disease affects 1% of people (P(A) = 0.01). A diagnostic test has 95% sensitivity (P(B|A) = 0.95) and a 5% false positive rate (P(B|A') = 0.05). If a patient tests positive, what is the probability they actually have the disease?

True Positives in 10,000 people: 10,000 × 0.01 × 0.95 = 95.

False Positives in 10,000 people: 10,000 × 0.99 × 0.05 = 495.

Total Positive Tests: 95 + 495 = 590.

Apply Bayes' rule: P(Disease | Positive) = 95 / 590 ≈ 0.1610 (16.10%).

Result: Only 16.10% chance of actually having the disease despite a 95% accurate test!

Tips & Key Notes

  • The "False Positive Paradox" occurs when screening for rare conditions: because the vast majority do not have the condition, false positives easily outnumber true positives.
  • Positive Predictive Value (PPV) heavily depends on base rate prevalence, not just the accuracy of the diagnostic test itself.

Frequently Asked Questions

Why is a 95% accurate medical test only 16% accurate if you test positive?

Because when a condition is rare (e.g. 1 in 100), the 99 healthy people produce vastly more false positive test results (approx 5) than the single sick person produces true positive results (~1).

What is the difference between prior and posterior probability?

Prior probability is your estimate before observing new evidence (e.g. general disease prevalence). Posterior probability is the revised estimate after incorporating the test result.

What is specificity?

Specificity is the True Negative rate: the probability that a healthy person tests negative. A test with a 5% false positive rate has a 95% specificity.

How do spam filters use Bayes' Theorem?

Naive Bayes spam filters calculate the probability an incoming email is spam given the presence of specific words (e.g. "free", "crypto", "wire transfer") based on historical training data.

Related Calculators

Explore similar tools