PROBABILITY & STATISTICS / 3. CONDITIONAL PROB & BAYES
Conditional, Joint & Marginal Probability + Bayes Theorem
Updating beliefs with evidence — the engine of probabilistic ML
EXPLANATION
Conditional Probability: P(A|B) = P(A ∩ B) / P(B)
"The probability of A given that B has already occurred."
This restricts the sample space to B, then asks how much of that restricted space is A.
Joint Probability: P(A ∩ B) = P(A|B) × P(B) = P(B|A) × P(A)
Marginal Probability: P(A) = Σ P(A ∩ Bᵢ) for all mutually exclusive Bᵢ
"Sum over all ways A can happen" — law of total probability.
Bayes Theorem:
P(A|B) = P(B|A) × P(A) / P(B)
In ML terms:
P(hypothesis | data) = P(data | hypothesis) × P(hypothesis) / P(data)
posterior = likelihood × prior / evidence
This is the foundation of:
• Naive Bayes classifier
• Bayesian neural networks
• MCMC sampling
• Bayesian optimization (hyperparameter tuning)DIAGRAM
Medical test example:
Disease prevalence P(D) = 0.01 (1% of population)
Test sensitivity P(+|D) = 0.95 (true positive rate)
Test specificity P(-|¬D) = 0.90 (true negative rate)
→ P(+|¬D) = 0.10 (false positive rate)
P(D|+) = P(+|D)×P(D) / P(+)
P(+) = P(+|D)×P(D) + P(+|¬D)×P(¬D)
= 0.95×0.01 + 0.10×0.99
= 0.0095 + 0.099 = 0.1085
P(D|+) = 0.0095 / 0.1085 ≈ 0.0876
Only ~8.7% chance you have the disease
even with a positive test! Prior matters a lot.CODE