Definition
The conditional probability of an event given an event , written , is the probability that happens when only the outcomes in which happens are counted. An event is a set of possible outcomes of a random experiment. The conditional probability equals and is defined only when . Conditioning on replaces the set of all outcomes by the part in which holds, so the denominator changes, and with it the question being answered.
The idea
A latency report says that 90% of the trials completed and that the completed trials took 300 ms on average. A reader takes 300 ms as the typical cost of an attempt. But the attempts that did not complete were cut off by a 5-second timeout §9.34, and they are the slowest attempts of all. Leaving them out removes the slow end. The figure of 300 ms is correct, but it answers ‘how long does an attempt take, given that it completed?’, not ‘how long does an attempt take?’.
Conditioning means zooming in on part of the population. Keep only the outcomes in which the condition holds, and ask what share of that part also has . The share can differ greatly from the share among all outcomes, because the condition can select outcomes that differ systematically from the rest. Completed trials are, by the meaning of completion, the trials that were fast enough.
How it works
Name the condition. State the event exactly, for example ‘the trial completed within the 5-second timeout’.
Restrict the outcomes. Keep only the outcomes in . Their total probability, , becomes the new whole.
Measure inside the restriction. Divide the probability that and both happen by . The result is the share of the kept outcomes in which also holds.
Report the probability of the condition. , here the completion rate, is a result in its own right. Without it, a reader cannot get from the conditional answer back to the answer about all attempts.
Three rules follow from the definition and are used constantly.
Multiplication rule: .
Law of total probability: if and ‘not ’ both have positive probability, then . The answer for all outcomes is a weighted mix of the answers for the two parts.
Bayes’ rule: when . It turns a conditional probability around.
Two events are independent when . When , this is the same as : learning that happened does not change the probability of . Conditioning changes the answer exactly when the events are not independent.
The same idea applies to averages. The conditional mean of a quantity given is its probability-weighted average over the outcomes in only. The average latency of completed trials is a conditional mean.
Worked example
A test runs 100 attempts with a 5-second timeout: 90 complete and 10 time out. Call an attempt slow if it takes more than 1 second. Of the 90 completed attempts, 10 are slow. A timed-out attempt ran for more than 5 seconds before it was stopped, so all 10 timed-out attempts are slow too: their full durations are unknown, but each is known to exceed 1 second. Let be ‘slow’ and be ‘completed’.
Slow and completed, as a share of all attempts: .
Slow among completed attempts: . The denominator changed from 100 to 90 because the question now counts only completed attempts. The definition gives the same value: .
Slow among all attempts: .
The law of total probability confirms the last value: . Conditioning on completion nearly halves the slow share, from 0.20 to 0.111.
The mean changes in the same way. Suppose the 90 completed attempts average 300 ms. If every timed-out attempt would eventually have finished, each would have taken more than 5000 ms, so the mean over all 100 attempts is more than ms. The conditional mean of 300 ms is less than half of that lower limit. Filling the unknown durations with zero, or dropping them, hides the difference. A duration known only to exceed a limit is a case of right censoring §11.28, which the censoring entry treats.
Stated precisely
Let be the set of possible outcomes of a random experiment, let give each event, a subset of , a probability, and let and be events with . Then where is the event that both and happen. The rule that maps each event to is itself a probability assignment: it gives probability 1 and every event that shares no outcome with probability 0. For a numerical quantity with a finite mean, the conditional mean is , where denotes the expected value, the probability-weighted average, and is the quantity that is 1 on outcomes in and 0 elsewhere.
Write for the event that does not happen. If and are both positive, the conditional and unconditional values are linked by . The conditional value equals the unconditional exactly when and are independent. Nothing in the notation makes that true. Independence is a property of the process that produced the data, and it must be argued or measured.
Limits and common mistakes
and are different numbers. In the example, the probability of slow given timed out is 1, but the probability of timed out given slow is . Swapping the two is a classic error. Bayes’ rule converts one into the other: .
Conditioning on a result of the trial, such as completion, selects a subgroup, and when the condition depends on the quantity being measured, as completion depends on speed, the selected group is biased. Survivorship bias §11.30 is the name for one form: studying only the cases that passed a selection step.
Conditioning can create a link between unrelated quantities. Toss two fair coins independently, and keep only the tosses in which at least one coin shows heads. Of the four equally likely outcomes, heads-heads, heads-tails, tails-heads and tails-tails, three remain. Among them, the first coin shows heads with probability . Among the kept outcomes in which the second coin shows tails, only heads-tails remains, so there the first coin shows heads with probability 1. Inside the kept group, the second coin’s result changes the probability for the first, although the coins were independent. This effect is called Berkson’s paradox, or collider bias.
Fixing the condition in advance, as a prospective exclusion rule §13.15 does, prevents choosing it after seeing the results. It does not make the selected group represent all attempts. Report the completion rate with its counts, the conditional result, and how the attempts outside the condition were treated.
The elementary definition needs . Conditioning on an event of probability zero, such as a continuous measurement taking one exact value, needs a more advanced definition.
Questions answered
Why does conditioning on completed trials change the question?
Conditioning on completed trials changes the question because it changes the population described: the result answers ‘how do attempts behave, given that they completed?’, not ‘how do attempts behave?’. Conditional probability counts only the outcomes in which the condition holds, so its denominator is the completed trials, not all trials. Completion is not independent of speed: an attempt that hits a timeout is, by definition, slow. Leaving out the timed-out attempts removes the slow end, so the conditional figures look faster than the figures for all attempts. The estimand §11.2, the quantity being estimated, has changed even if every calculation is correct.
With 100 attempts, 90 completed, 10 of the completed ones slow (over 1 second) and 10 timed out after 5 seconds, the slow share is among completed attempts but among all attempts. Report the completion rate and the conditional latency separately, and treat timed-out attempts as censored, known only to exceed the timeout, never as zero.
Related entries: Censoring (§11.28), Missing data and attrition (§11.29), Survivorship bias (§11.30), Prospective exclusion rule (§13.15), Estimand and estimator (§11.2), Union bound (§15.42).