Conditional Probability Calculator
Apply Bayes' theorem to find conditional probabilities, intersections, and unions of two events. Useful in medical testing, risk analysis, and machine learning evaluation.
About this calculator
Conditional probability quantifies how the likelihood of one event changes given that another has occurred. The core formula is P(A|B) = P(A ∩ B) / P(B), where P(A ∩ B) = P(A) × P(B|A) is derived from the multiplication rule. Bayes' theorem rearranges this to update beliefs: P(A|B) = [P(B|A) × P(A)] / P(B). The union formula is P(A ∪ B) = P(A) + P(B) − P(A ∩ B), subtracting the intersection to avoid double-counting. This calculator also handles P(A|B̄) — the probability of A given that B did NOT occur — using P(A ∩ B̄) = P(A) × P(B̄|A) and dividing by P(B̄) = 1 − P(B). These relationships underpin medical diagnosis, spam filtering, and any reasoning under uncertainty.
How to use
Suppose a disease affects 1% of a population: P(A) = 0.01. A test correctly detects the disease 90% of the time: P(B|A) = 0.90. The overall positive-test rate is P(B) = 0.108 (accounting for false positives). Set prob_a = 0.01, prob_b = 0.108, prob_b_given_a = 0.90, calculation_type = 'a_given_b'. The intersection = 0.01 × 0.90 = 0.009. P(A|B) = 0.009 / 0.108 ≈ 0.0833. Despite a positive test, there is only about an 8.3% chance the patient actually has the disease — a classic base-rate fallacy illustration.
Frequently asked questions
What is the difference between P(A|B) and P(B|A) in conditional probability?
P(A|B) asks: given that B has already occurred, how likely is A? P(B|A) asks the reverse: given A has occurred, how likely is B? These two quantities are generally not equal and confusing them is called the 'inverse fallacy' or 'transpose fallacy.' Bayes' theorem is precisely the tool for converting one into the other: P(A|B) = P(B|A)·P(A)/P(B). In medical testing, P(positive|disease) is the test sensitivity, while P(disease|positive) is what the patient actually wants to know.
How does Bayes' theorem apply to real-world probability problems?
Bayes' theorem lets you update a prior belief P(A) with new evidence B to produce a posterior probability P(A|B). It is used in spam filters (updating the probability an email is spam given certain words), medical diagnosis (updating disease probability given a positive test), and machine learning classifiers. The key insight is that the posterior depends heavily on the prior — a rare disease remains unlikely even after a positive test if the base rate P(A) is very low, as demonstrated by the classic medical testing paradox.
When are two events considered independent in probability theory?
Two events A and B are independent when P(A ∩ B) = P(A) × P(B), which equivalently means P(A|B) = P(A) — knowing B occurred gives no information about A. Independence is a special case that simplifies calculations considerably. In practice, true independence is rare: coin flips and dice rolls are independent, but most real-world events (disease and symptoms, weather and accidents) are correlated. This calculator handles the general dependent case via P(A ∩ B) = P(A) × P(B|A), which reduces to P(A) × P(B) only when A and B are independent.