Understanding Conditional Probability
Definition:
P(A|B) = P(A ∩ B) / P(B)
Bayes' theorem form (used by this calculator):
P(A|B) = P(B|A)·P(A) / [ P(B|A)·P(A) + P(B|¬A)·(1 − P(A)) ]
The probability of A given that B has occurred, for P(B) > 0
Conditional probability answers the question: given that event B has happened, how likely is event A? It is defined as the joint probability of both events, P(A ∩ B), divided by the probability of the conditioning event, P(B). This is only defined when P(B) is greater than zero — you cannot condition on something that never occurs.
In many real problems you do not directly know the joint probability P(A ∩ B) or the marginal P(B). Instead you know three quantities: the prior P(A) (how common A is before you see any evidence), the sensitivity P(B|A) (how often the evidence B shows up when A is true), and the false-positive rate P(B|¬A) (how often B shows up when A is false). Bayes' theorem stitches these together. The denominator is the law of total probability: P(B) = P(B|A)·P(A) + P(B|¬A)·(1 − P(A)), splitting every occurrence of B into the "A was true" branch and the "A was false" branch. This calculator implements exactly that expression.
How the calculator works
Enter each value as a decimal between 0 and 1. With the default medical-screening example — prior P(A) = 0.01, sensitivity P(B|A) = 0.99, false-positive rate P(B|¬A) = 0.05 — the joint probability is 0.99 × 0.01 = 0.0099, the total probability of a positive is 0.0099 + 0.05 × 0.99 = 0.0594, and the posterior is 0.0099 / 0.0594 ≈ 0.1667, or about 16.7%. A "99% accurate" test on a 1-in-100 condition still leaves you more likely to be healthy than sick after a positive result.
Related probability rules
- Multiplication rule: P(A ∩ B) = P(A) × P(B|A). Rearranging this definition is where the P(A ∩ B) / P(B) formula comes from.
- Law of total probability: P(B) = P(B|A)·P(A) + P(B|¬A)·P(¬A). This is the denominator in Bayes' theorem.
- Complement: P(¬A|B) = 1 − P(A|B). The calculator reports this as the fourth output.
- Independence: if A and B are independent, P(A|B) = P(A) — knowing B tells you nothing about A. You can check this by setting sensitivity equal to the false-positive rate; the posterior then collapses back to the prior.
Common intuition traps
- Base-rate neglect: people fixate on the test's accuracy and ignore how rare A is. When the prior is tiny, even an excellent test produces mostly false positives, so P(A|B) stays low.
- Confusing P(A|B) with P(B|A): "the probability of a positive test given the disease" (sensitivity) is not "the probability of the disease given a positive test" (the posterior). Swapping these is the prosecutor's fallacy.
- Assuming symmetry: P(A|B) and P(B|A) are only equal when P(A) = P(B). In general they can differ enormously.