Conditional Probability
Conditional probability updates the chance of an event once you learn that another event has occurred.
Definition
The probability of A given B, written P(A | B), is defined when P(B) > 0 as P(A | B) = P(A ∩ B) / P(B). Conditioning on B restricts attention to the outcomes inside B and renormalizes so that B becomes the new certain event.
The multiplication rule
Rearranging gives P(A ∩ B) = P(A | B) P(B) = P(B | A) P(A). This chains: P(A ∩ B ∩ C) = P(A) P(B | A) P(C | A ∩ B). The chain rule is the backbone of sequential models such as Markov chains and probabilistic programs.
A worked example
Suppose a diagnostic flags 5% of good components and 90% of faulty ones, and 2% of components are faulty. The probability that a flagged component is actually faulty is not 90% — it depends on the base rate, and conditional probability is the tool that resolves this.
p_fault = 0.02
p_flag_given_fault = 0.90
p_flag_given_good = 0.05
p_flag = p_flag_given_fault*p_fault + p_flag_given_good*(1-p_fault)
p_fault_given_flag = p_flag_given_fault*p_fault / p_flag
print(round(p_fault_given_flag, 4)) # 0.2687
A common trap
P(A | B) is generally not equal to P(B | A). Confusing the two is the base-rate fallacy: a test that is 90% sensitive can still produce mostly false alarms when the condition it detects is rare. Keeping the direction of conditioning explicit avoids this error.
Conditioning is also how independence is tested: A and B are independent exactly when learning B changes nothing, P(A | B) = P(A).