Conditional Probability

Conditional probability changes the reference population. For events and in a probability space, with ,

This definition is the algebraic base for Bayes’ theorem, diagnostic tests, classifier calibration, and likelihood calculations in hypothesis testing.

Intuition

Conditioning discards outcomes outside and renormalizes the remaining mass to one. The event is then evaluated only inside that narrowed sample space. This is why and can be very different.

Worked computation

The simulation below repeats the disease-testing base-rate scenario from Bayes’ theorem and compares the simulated conditional probability with the exact calculation.

import numpy as np
 
rng = np.random.default_rng(20260711)
N = 500000
disease = rng.random(N) < 0.01
positive = np.where(disease, rng.random(N) < 0.99, rng.random(N) < 0.05)
exact = (0.99 * 0.01) / (0.99 * 0.01 + 0.05 * 0.99)
print("sim_P(disease|positive)", round(disease[positive].mean(), 4))
print("exact", round(exact, 4), "positive_rate", round(positive.mean(), 4))

Observed output:

sim_P(disease|positive) 0.1646
exact 0.1667 positive_rate 0.0596

The simulation gives , close to the exact value 0.1667. Even with 99 percent sensitivity, most positives are false positives because the positive rate is only about 0.0596 and the false-positive term is applied to the much larger healthy group.

Caveats

Conditioning on a post-treatment event, selected sample, or model flag can introduce selection bias. Independence is a special claim: , not the default.

References