Conditional probability and conditional expectation
The lesson "Probability spaces and Kolmogorov's axioms" turned probability into a measure of total mass one on a space of outcomes, "Expectation, variance and inequalities" defined the expectation as the integral of a random variable against that measure, and "Independence and product measures" introduced the conditional probability in brief, as the tool that independence needed. All of these describe a state of knowledge in which nothing has been observed. This lesson asks what changes when part of the answer is revealed. It starts with conditioning on a single event, derives the multiplication rule and Bayes' rule, and then moves to the conditional expectation of a random variable given a partition and finally given a σ-algebra, which is the best prediction that the information at hand allows.
Conditional probability
Recall the two dice of "Independence and product measures", with outcomes , on the first die and on the second. A sum of 8 has probability , and once you are told that the first die shows 3, only the six outcomes remain, one of which, , has sum 8, so the probability becomes . This lesson starts again from that example and develops conditioning in full.
The recipe behind this calculation is to shrink the space of outcomes to the event that was observed, and then rescale so that the total probability is 1 again. For events and with , the conditional probability of given is
In words: take the part of that lies inside and measure it against the size of . The numerator discards everything outside , and the division by makes itself have probability . In frequency terms: throw the dice many times, keep only the throws whose first die shows 3, and about of those have sum 8.
As "Independence and product measures" noted, the new probability is itself a probability measure on the same events, and the check is short. Its values are non-negative, being ratios of non-negative numbers; it gives the sure event the value ; and for disjoint events the pieces are disjoint too, so countable additivity of gives
Every rule derived from the axioms in "Probability spaces and Kolmogorov's axioms" therefore holds for conditional probabilities as well. For instance . Information can raise or lower a probability. The chance that the sum is at least 10 is . Given that the first die shows 6, three of the six possible outcomes reach it and the probability is ; given that it shows 1, none does and the probability is 0.
Conditioning is not symmetric. Reverse the roles in the example above and ask for the probability that the first die shows 3 given that the sum is 8. Only five outcomes have sum 8, and exactly one of them has a 3 in front:
The numerators agree, since both describe the outcome , but the denominators differ: one universe has six outcomes and the other five. Confusing the two conditional probabilities is the most common mistake in the subject, and the section on Bayes' rule shows how costly it can be.
The formula needs ; otherwise it reads . This is more than a technicality: a number drawn uniformly from equals any given value with probability zero, yet conditioning on information about it can make sense. The section on σ-algebras defines conditioning without dividing by the probability of the observation.
The multiplication rule and total probability
Multiplying the definition by gives the multiplication rule:
In words: the chance that both events happen is the chance that the first happens, times the chance that the second happens once the first has. Applying the rule twice extends it to chains,
Take an urn with 3 red and 2 blue balls and draw three balls without putting any back. The first is red with probability . Given that, 2 red balls remain among 4, so the second is red with probability ; given both, 1 red ball remains among 3. The chance that all three are red is , which agrees with counting: one of the 10 equally likely sets of three balls consists of the three red ones.
The second rule splits a probability into cases. A partition of is a list of disjoint events of positive probability that together cover , as in "σ-algebras and Borel sets". Any event falls apart into the disjoint pieces , and adding their probabilities, each written with the multiplication rule, gives the law of total probability:
In words: the probability of is a weighted average of its probabilities in the separate cases, and the weights are the probabilities of the cases. Split the two dice by the value of the first die. Each case has probability . Given first , a sum of 8 is impossible; given first the second die must show one particular number, so the conditional probability is . Then
as it should be. A second example: in the same urn, with nothing known about the first draw, the second ball is red with probability , exactly the probability that the first ball is red. The idea of weighting case-by-case answers by the probabilities of the cases returns below, with expectations in place of probabilities.
Bayes' rule
The multiplication rule can be applied in two orders, . Dividing by turns one conditional probability into the other. This is Bayes' rule:
The denominator can be expanded with the law of total probability. The reading is a change of beliefs: is the prior, the probability of before anything is observed, and is the posterior, its probability after has been observed.
Here is the standard example. A disease affects 1% of a population, so the prevalence is . A test comes out positive for 99% of the ill people, a figure called the sensitivity, . It comes out negative for 95% of the healthy people, called the specificity, , so it is positive for the other 5% of the healthy. A randomly chosen person tests positive. How likely is it that this person is ill? Many people answer something close to 99%. The multiplication rule gives the two ways of being positive:
Their sum is , by the law of total probability, and Bayes' rule gives
The same calculation with people instead of probabilities makes the result easier to believe. Take 10,000 people. Of them 100 are ill and 99 of those test positive. The other 9,900 are healthy and 5% of them, 495 people, test positive too. In total 594 people are positive, and only 99 of them are ill: .
The intuition fails because of the base rate. The sensitivity answers , but the question asked was the reverse, , and these are different numbers. Few people are ill, so even a small false-alarm rate, applied to the many healthy people, produces more false alarms (495) than true detections (99). A strong test lifts a probability of 1% to 16.7%, not to 99%.
Posteriors can be updated again: if the person takes a second test and it is also positive, the posterior of the first test becomes the prior of the second. The two results are taken to be independent once the person's true health state is fixed. The worked example carries out both steps.
Conditional expectation given an event
The conditional measure is a probability measure, so it has expectations like any other. The conditional expectation of a random variable given an event with is the expectation of computed under :
In words: average over only, with the weights given by , and rescale by the size of . The indicator switches off outside , so the numerator is the integral of over , and the denominator turns it into an average.
Let be the face of one die and the event that the face is even. Then , , and , which is simply the average of the three equally likely faces 2, 4 and 6. For the odd faces the same computation gives 3. With two dice, , because the five outcomes with sum 8 are equally likely. Without information the first die averages , so learning that the sum is 8, above the typical 7, moves the best guess up to . For a fixed event is a single number; the next section lets the event depend on the outcome.
Conditional expectation given a partition
Imagine an observer who does not see the outcome but is told which block of a partition it lies in. "σ-algebras and Borel sets" described such an observer by the σ-algebra of all unions of blocks, whose atoms are the blocks themselves. What should this observer predict for a random variable ? Inside block the natural prediction is . This prediction depends on only through the block, so it is a random variable, called the conditional expectation of $X$ given $\mathcal{G}$:
In words: flatten on every block to its average over that block. The result is constant on each atom of , and by "Measurable functions" that is exactly what it means for a function to be measurable with respect to a σ-algebra generated by a partition. So is -measurable: it uses no information beyond the blocks.
Take the face of a die with four different observers. One sees only the parity, with blocks and , and predicts on the first and on the second. One sees only whether the face is at most 2, with blocks and , and predicts and . One sees nothing, so the only block is and the prediction is the constant . One sees the face itself, all six blocks are single points, and the prediction is . The more the observer knows, the closer the prediction follows .
For a larger example, let be generated by the sum of the two dice, which has 11 possible values and so 11 blocks. By symmetry, : the outcomes and have the same sum and are equally likely, so within every block the two dice have the same average, and these two averages add up to the sum. For sum 7 the block has six outcomes and the average is ; for sum 8 it is , for sum 12 it is , and for sum 2 it is .
The block averages, weighted by the probabilities of the blocks, add up to the plain expectation. This is the law of total expectation:
The first equality weights each block average by its probability, the second uses the definition of , and the third adds up the pieces of . The parity observer gives , the "at most 2" observer , and the dice-sum observer : each time the expectation of one die.
Conditional expectation given a σ-algebra
Partitions are not enough. Let be uniform on and let be its distance from the middle. An observer who is told knows that is one of the two points and , but each event has probability zero, so reads . Still, "what is the average of given ?" has an obvious answer: the two points are equally likely, so it is , which is for and for . A definition is needed that produces such answers without dividing by a zero probability. The way out is to say what the answer must satisfy, instead of how to compute it.
Let be an integrable random variable and let be a sub-σ-algebra, the events the observer can decide. The conditional expectation is a random variable with two properties:
Property (i) says that is built from the observer's information alone: every question about , such as "is at most 0.3?", is one that can answer. Property (ii) says that on every event the observer can name, has the same total as , so carries no bias. It is with all the detail that cannot see averaged away.
Block averages satisfy both properties. A block average is constant on each block, which is (i). For , , and every other is a union of blocks, over which both sides add up. The distance example passes as well. Take , which has probability . On one side . On the other, and has density 2 on , so .
Is there such a , and is it the only one? Uniqueness has a short proof. Suppose and both satisfy (i) and (ii). The event belongs to , and by (ii) . The integrand is positive on , so is a null set; the same holds for , hence almost surely. Conditional expectation is determined up to a null set, and equalities between conditional expectations are always meant almost surely. Existence for every integrable is the Radon–Nikodym theorem, which a later lesson of this track states. For a partition, the explicit formula above provides it.
The most common case is conditioning on a random variable . Then means , where is the σ-algebra of the events from "Measurable functions". A -measurable random variable is a function of , so for some function , and the value is what one calls . For the dice, ; for the distance example, .
A conditional expectation is a random variable, not a number: it takes a value for each , namely the best answer given what has revealed about . Only , for a fixed event, is a number.
A concrete σ-algebra comes from the coin model of "Probability spaces and Kolmogorov's axioms", where a uniform is read as an infinite sequence of fair coin tosses, its binary digits. Knowing the first tosses means knowing which of the dyadic blocks contains , and the σ-algebra generated by these blocks is the observer after tosses. For and the blocks are the four quarters of , and the block averages are , that is , , and . Their average is . With no tosses known the prediction is the constant ; after one toss it is on the left half and on the right half.
The figure shows this staircase. Choose a variable , move the slider from 0 to 4 and watch: at the staircase is one flat line at , and every extra toss splits each block in two, so that it follows more closely. The first readout does not change with , because the block averages always average to . At the defaults, and , there are four blocks, , and the error readout shows , which the next section explains. Switch on the comparison guess to see a second staircase.
- Mean of X
- 0.3333
- Blocks
- 4
- Error of 𝔼[X | 𝒢]
- 0.006858
- Error of the guess
- –
Raise k to reveal more tosses: each block splits in two and the staircase of block averages follows X more closely. With the guess on, the dashed staircase shows X at the midpoint of each block, and its error is never smaller.
Best prediction
Why average within a block, and not take another value? Because the average is the best prediction in a precise sense. Suppose the observer must predict with a -measurable random variable with , and measure its quality by the mean squared error . Without information must be a constant, the best constant is , and the error is the variance of from "Expectation, variance and inequalities". The claim is that with information, is the best of all.
The proof has two steps. First, is orthogonal to everything the observer can build: for every -measurable with finite second moment. For with this is exactly property (ii), because . Linearity extends it to finite sums , and a general is a limit of such sums (an idea, not a complete proof). Second, write . The difference is -measurable, so the cross term vanishes by orthogonality, and the squares add:
The second term is never negative, and it is zero only if almost surely. So is the best prediction, and every other prediction is worse by exactly the squared distance to . This is Pythagoras' theorem for random variables: is perpendicular to everything can build.
The figure's numbers illustrate it. For and four blocks, the best staircase has error . Take instead the guess that evaluates at the midpoint of each block, with values . Each differs from the block average by , so the extra error is and the guess has error , which is what the figure shows when the comparison guess is on. The guess is good, since squares are nearly linear on short blocks, but it cannot beat the block average.
More information can only help. If , every -measurable prediction is also -measurable, so the minimum over the larger class is at most the minimum over the smaller one. For the error is with 1 block (no tosses known), then , and with 2, 4 and 8 blocks. Each extra toss cuts the error by a factor of 3.4, 3.8 and then 4.0. Applying the Pythagoras identity to the constant prediction also splits the variance in two parts:
The first part is what the information leaves unexplained, the second is what it explains. With four blocks, : the first two tosses explain about 92% of the variance of .
Rules of conditional expectation
All the rules below follow from the two defining properties and have a simple block picture. They hold almost surely, since a conditional expectation is determined only up to a null set.
Linearity. . Averaging over a block is a linear operation. For two dice, , which is . Monotonicity goes with it: if then , because averaging preserves order.
Taking out what is known. If is -measurable, then
Inside a block, is a constant, and a constant factors out of an average. For two dice, is known once the sum is given, so ; given sum 8 the value is , which is times the block average . With the rule gives : what the observer knows does not need predicting.
The tower property. If , then
In words: predicting from the finer information and then forgetting the details down to is the same as predicting from directly, so the coarser information wins. Each coarse block is a union of fine blocks, and its average is the probability-weighted average of their averages. For , going from four blocks to two: the left half has fine averages and , with mean , and the right half has and , with mean , exactly the two-block averages found above. The trivial σ-algebra for gives the law of total expectation.
Independence. If is independent of , in the sense of "Independence and product measures", then : information that has nothing to do with leaves the prediction unchanged. For two dice, . The figure shows a more surprising case. The values of at mirror points and agree, so the two halves of look alike and the first toss says nothing about . Choose this and set : both block averages equal , and the error stays at its no-information value .
Conditional Jensen. If is convex, then , which is Jensen's inequality from "Expectation, variance and inequalities" applied inside every block. With the gap in a block is the variance of inside it: for on the block , , the square of the block average is , and the difference is the variance of within that half.
Summary
- shrinks the space to and rescales; it is a probability measure, but in general.
- The multiplication rule, the law of total probability and Bayes' rule follow from the definition; with a base rate of 1%, a positive result from a 99% sensitive, 95% specific test means illness with probability only .
- Given a partition, replaces by its average on each block, and the block averages average back to .
- Given a σ-algebra, is the -measurable random variable with the same integral as over every event of ; it is unique up to a null set.
- It is the best mean-squared prediction of from : any other is worse by the squared distance to it, and more information never increases the error.
- The rules: linearity, monotonicity, taking out what is known, the tower property, independence, conditional Jensen.