Vary P(B|A) from 0 to 1 and see how P(A|B) changes in real time. The line chart shows the posterior probability as a function of the likelihood.

01
P(B|A) = 0.90

The 2×2 diagnostic testing matrix shows true/false positives and negatives based on disease prevalence (P(A)), sensitivity (P(B|A)), and specificity (1−P(B|¬A)).

Conditional probability answers the question: "Given that B has happened, what's the probability that A also happens?" It updates our knowledge based on new information. This is the mathematical foundation of learning from experience — every time you update a belief after receiving new evidence, you are performing conditional probability. Our conditional probability calculator computes P(A|B) directly, and our Bayes theorem calculator reverses the condition.

The Formula

P(A|B) = P(A ∩ B) / P(B)

Read as "Probability of A given B." We restrict our attention to only the outcomes where B occurs, and ask what fraction of those also include A. For example, in a deck of cards, the probability of drawing a king given that you've drawn a face card is P(king | face card) = (4/52) / (12/52) = 4/12 = 1/3 ≈ 33.3%.

Bayes Theorem

P(A|B) = P(B|A) × P(A) / P(B)

Where P(B) = P(B|A)×P(A) + P(B|¬A)×P(¬A). Bayes theorem tells us how to reverse conditional probability — from P(B|A) to P(A|B). This is the foundation of Bayesian statistics and diagnostic testing.

Sensitivity Analysis

The sensitivity analysis tab lets you explore how the posterior probability P(A|B) changes as the likelihood P(B|A) varies from 0 to 1. The interactive slider updates the line chart in real time, showing the functional relationship. This is particularly useful for understanding how test accuracy affects diagnostic confidence.

Likelihood Ratios

The positive likelihood ratio LR+ = P(B|A) / P(B|¬A) measures how much the odds of the hypothesis increase when the evidence is observed. The negative likelihood ratio LR− = (1−P(B|A)) / (1−P(B|¬A)) measures the decrease in odds when the evidence is absent. Post-test odds = prior odds × LR. A LR+ greater than 10 provides strong evidence for the hypothesis.

Worked Example (Medical Test)

A disease affects 1% of people (P(A)=0.01). The test is 90% accurate for those with the disease (P(B|A)=0.9) and has a 5% false positive rate (P(B|¬A)=0.05). If you test positive, P(A|B) = 0.9 × 0.01 / (0.9×0.01 + 0.05×0.99) = 0.009 / 0.0585 ≈ 0.154 = 15.4%. Even with a positive test, there's only a 15.4% chance you have the disease — because the disease is rare and false positives outnumber true positives. This is the base rate fallacy in action.

Why does conditional probability matter?
It's how we learn from evidence. Every time you update a belief based on new information, you're doing conditional probability — often using Bayes theorem.
What's the base rate fallacy?
Ignoring how rare (or common) a condition is when interpreting test results. A 99% accurate test for a 1-in-10,000 disease still gives mostly false positives.
Can P(A|B) be larger than P(A)?
Yes — that's the whole point. Learning that B occurred can increase (or decrease) the probability of A. If P(A|B) > P(A), then B is evidence in favor of A.
What is a likelihood ratio?
LR+ = P(B|A)/P(B|¬A). It quantifies how much a positive test result changes the odds of having the condition. LR+ > 10 is considered strong evidence.

Bayes theorem is one of the most powerful tools in statistics, with applications spanning medical diagnosis, machine learning, spam filtering, and scientific research. In medical testing, Bayes theorem calculates the probability that a patient actually has a disease given a positive test result, accounting for the disease's prevalence (base rate) and the test's accuracy.

Machine learning algorithms, particularly naive Bayes classifiers, use Bayes theorem for text classification, sentiment analysis, and recommendation systems. Spam filters use Bayesian inference to update the probability that an email is spam based on the words it contains. In scientific research, Bayes theorem provides a framework for updating beliefs as new evidence emerges.

The base rate fallacy — ignoring how rare a condition is when interpreting test results — is one of the most common and costly errors in probabilistic reasoning. Our conditional probability calculator helps avoid this by showing the full Bayesian calculation, including the prior probability, likelihood, and posterior probability, with complete step-by-step work.

Key Formulas

P(A|B) = P(A∩B)/P(B)

P(A|B) = P(B|A)P(A)/P(B)

P(B) = P(B|A)P(A) + P(B|¬A)P(¬A)

LR+ = P(B|A)/P(B|¬A)

LR− = (1−P(B|A))/(1−P(B|¬A))