Movement III: Two Random Variables
EE 520: Random Processes (Fall 2026). Instructor: John Lipor.
Session 3 turned beliefs into actions when the actions were discrete: search here or there. Today the action is a number. A posterior distribution over the target’s range is a whole curve; the operator wants one figure, “your best guess of the range.” What single number should a posterior become? This session answers it. The best guess of from an observation turns out to be the conditional expectation , and, crucially, it is itself a random variable, a function of the data. That is exactly what an estimator is, so this session builds the first genuine estimator of the course.
Fix a value . The conditional density (or PMF) is a genuine distribution, so it has an expectation like any other:
Definition 1 (Conditional expectation given a value).
This is one number for each : the mean of the posterior over once we know . Take the detection table of Session 8 (prior , , ). Because is an indicator, its conditional expectation is just a conditional probability: So the map takes exactly two values, one for each possible reading.
Here is the step that trips up nearly everyone. Collect those per-value answers into a single object that reads and returns the matching number:
Two objects, one symbol, and keeping them straight is the whole battle: is a number (you have plugged in a value), while is a random variable (you have not).
The single most useful identity about conditional expectation says that averaging the conditional guesses recovers the plain average.
Theorem 1 (Tower property). For any random variables and with ,
Proof. Take discrete (the continuous proof is identical with integrals in place of sums). By definition and then regrouping the double sum, using (the chain rule) and then summing out to recover the marginal . ◻
The outer expectation is over : we average the conditional guess across all the readings might produce, weighted by how likely each is. This is the computational workhorse of the movement, and it powers both proofs below.
Conditioning also splits variance into two honest pieces.
Proposition 1 (Law of total variance).
Proof. Write and take expectations, using the tower property on each term: Meanwhile, since by the tower property, Adding the two lines, the middle terms cancel and remains. ◻
The two terms have clean readings, and both outer operations are over . is the unexplained scatter, the variance still left inside once is known, averaged over . is the explained variation, how much the best guess itself moves as varies. Since the two terms sum to the fixed total , an observation cannot remove uncertainty, only reassign it: a useful is one that shifts variance out of the first term and into the second.
Call the mean squared error of the guess . Among all functions , one is unbeatable.
Theorem 2 (MMSE property). The mean squared prediction error is minimized over all functions by .
Proof. Add and subtract and expand: where the cross term is with a function of . Condition on and use the tower property: since is known once is, The cross term vanishes, so which is smallest exactly when the second term is zero, i.e. when . ◻
This is Session 2’s Bayes rule, now read as an estimator: the posterior it produces gets compressed into one number by taking its mean.
An estimate is a compression of the posterior. The posterior mean is the answer to “what single number should I report under squared-error loss?” An estimate is a compression of the posterior, chosen for a purpose; change the purpose and you change the summary. Other loss functions select other summaries (the median under absolute error, the mode when we detect in Session 10), but throughout this course, unless we say otherwise, the estimate is the posterior mean.
The tower property shines when even the number of terms is random. Suppose targets are present, with itself random, and each present target is detected independently with probability ; let be the detected count. Conditioning on makes an ordinary sum of indicators, so , and the tower property finishes it: The mean detected count is the detection probability times the mean target count, whatever the distribution of . The full distribution of (a thinned count) is HW4; here the tower property handed us its mean with almost no work.
Remark 1 (Freezing what you condition on). The step quietly used two moves that recur whenever is built from and other randomness . First, given , the value may be substituted for inside the expectation: . Second, if is independent of , conditioning no longer changes the distribution of , so the condition can be dropped: . Here , , and , which gives . So nothing in the tower property requires to be unrelated to : may be any function of and other random variables, and conditioning on freezes while leaving the rest random. Without independence the second move fails, and the conditional distribution of given must be used instead.
Return to Session 8’s uniform pair on (the range and the error magnitude ). There the model’s conditional density was on : given the range, the error is uniform up to twice the range. The mean of a uniform on is its midpoint, so The best guess of the error equals the range: a regression line through the origin with slope (Figure 1). Notice it is a genuine function of the data , exactly the promotion above.
Now verify the tower property two ways. Averaging the conditional guess against the marginal , Computing directly against the marginal on (the slice at height runs from the edge to ), Both routes give : the roundabout tower computation and the direct one agree, as they must.
For the table, the conditional expectations computed above, and , are literally the posterior probabilities of Session 2. The reason is that is an indicator, and the expectation of an indicator is the probability of the event it flags. As a check, the tower property returns the prior: , the marginal .
Movements I and III meet. For an indicator , “posterior probability” (Movement I) and “conditional expectation” (Movement III) are the same number. Detection was never a separate subject: it is conditional expectation of a quantity, which is why Session 10 will need nothing new to decide present versus absent.
A building has floors. people board at floor 1, and each rider, independently of the others and of , exits at one of the floors , all equally likely. On average, at how many floors does the elevator stop to let someone off?
The tempting route is to find the distribution of the number of stops first. That is genuinely messy: whether the elevator stops at floor 3 and whether it stops at floor 4 are dependent events, since the floors compete for the same riders. The mean does not need the distribution. Write as a sum of indicators, and use linearity of expectation, which holds whether or not the are independent. The expectation of an indicator is a probability (example (b)), and by symmetry every floor has the same one, so To find , condition on and use the tower property. Given , freeze at ; the riders’ floor choices are independent of , so the condition drops (Remark 1), and each of the riders independently avoids floor with probability : Averaging over the Poisson distribution of , the series is the exponential series: Therefore With there are ten exit floors and ten riders expected, one per floor on average, yet : riders clump, so the elevator skips more than a third of the floors. Two sanity checks at the extremes. With a single exit floor (), , as it must be. With very many floors, : riders almost never share a floor, so every rider is a stop and .
A commuter chooses among routes. Each route has a systematic appeal that an analyst could estimate from travel time and cost, plus an idiosyncratic part (mood, weather, a podcast that runs long) that the analyst cannot see. Model the commuter’s utility for route as and assume the commuter takes the route with the largest utility. The analyst sees only the choice. What is the probability that route is chosen?
Theorem 3 (Gumbel-max). Under this model, for each ,
The right side is the softmax of . The proof reduces an -way race to a two-way race, and the two-way race is a tower-property computation on an indicator, the move of examples (b) and (c).
Lemma 1 (Two-way race). If and are independent, then .
Proof. Write for the density of and for the CDF of . The probability of an event is the expectation of its indicator, so by the tower property In the tower property’s terms, the variable being averaged is , which depends on both and , and the variable conditioned on is . Given , freeze at ; then, since is independent of , drop the condition (Remark 1): Averaging over , which is also what Session 8’s iterated integral of the product density over gives. Insert the Gumbel density and CDF and collect the double exponentials: Substitute , so , and running from to sends from down to : Because and are continuous, , so . ◻
Proof of Theorem 3. Route wins exactly when , where is the best of the other routes. Each is , so by Session 6’s max-stability proposition, with . And is independent of , because it is a function of , , only. Lemma 1 with and gives This is the softmax, as claimed. ◻
Three routes. Take . Route 3 faces the best of routes 1 and 2, which by max-stability is : a soft maximum a little above route 2’s . Route 3 wins that race with probability , and the full choice pmf is . A Monte Carlo run of simulated commuters reproduces these to three decimals.
Two routes. With , dividing through by , the logistic function of the difference in appeal. For pairwise comparisons this is the Bradley–Terry model, which is the probability model underneath Elo ratings in chess: a gap of one unit of appeal gives the stronger side a win probability of . If you worked Homework 3 Problem 6, you have already met this two-route case from the other direction: there came out logistic from a wedge integral over two exponentials, and the hard switch was on with probability , which is this formula with .
Softmax is an argmax under noise. The softmax is not an arbitrary way to turn scores into probabilities. It is exactly the distribution of the winner when each score receives independent Gumbel noise and the largest noisy score wins. This random-utility reading is the foundation of discrete-choice modeling in economics (McFadden, Nobel 2000), and it is also the softmax in machine learning.
Back to Session 7’s token sampler. Take scores for logits and temperature . By the theorem, has exactly the temperature pmf of Session 7’s AI corner. Multiplying inside the argmax by does not change the winner, so the same draw is : temperature is the noise level. As the noise vanishes and the argmax becomes greedy decoding; as grows the noise swamps the logits and every token becomes nearly equally likely. This Gumbel-max trick draws a sample without ever computing the normalizing sum , using one per token from Session 7’s Gumbel sampler.
Pitfall. Only differences of the matter. Adding the same constant to every multiplies the numerator and the denominator of [eq:softmax] by and changes no choice probability. So a single appeal such as “” carries no meaning on its own, and an analyst who estimates appeals from choices must fix one of them (say ) before the others are determined.
Work these in class.
(Mechanical: conditional expectation and the tower
check.) A pair
with
,
has joint PMF
,
,
,
.
Find
and
,
then confirm the tower property gives
.
Answer: column totals
,
,
so
and
.
Tower:
.
(Conceptual: does conditioning reduce variance?) A
classmate says “knowing
always shrinks the variance of
.”
Correct the statement.
Answer: Only on average. The law of total variance
gives
,
so the average conditional variance cannot exceed
;
but a particular
can be larger than
(an unusual reading can leave you more uncertain, not less).
The course thesis asks how observation should change belief and action. When the action is a number, the best it can be under squared error is the conditional expectation , the mean of the posterior. The hardest idea was that this best guess is a random variable, a function of the data, which is what makes it an estimator rather than a static answer. The tower property let us average conditional guesses back to the unconditional mean and, through the add-and-subtract argument, certified as the minimizer of mean squared error; the law of total variance split uncertainty into what an observation explains and what it leaves behind. Writing a count as a sum of indicators and conditioning on the random number of riders gave the elevator’s expected stops without ever finding their distribution. Applied to an indicator, the tower property also showed that adding independent Gumbel noise to a set of scores and taking the argmax produces exactly the softmax, the probability model behind discrete choice and behind sampling from a language model. Reading an estimate as a compression of the posterior chosen for a purpose is the throughline into the estimation half of the course. Next session specializes all of this to a target: detection is conditional expectation of an indicator, compared to a threshold, and Session 2’s likelihood ratio returns as the decision statistic.
Is
a number or a random variable, and why does the distinction
matter?
Answer: A random variable, the function
with
.
It matters because an estimator must be a function of the data;
(a specific reading plugged in) is the number,
is the rule.
State the tower property and use it in one line to find
when
with the
independent
Bernoulli
and
random.
Answer:
.
Here
.
Why is the posterior mean, and not the whole posterior, what we
usually report, and when might that be the wrong choice?
Answer: Under squared-error loss the posterior mean is the
optimal single-number summary (the MMSE property), a useful compression
of the full posterior. It is the wrong choice when the loss is
different: absolute error wants the median, and a detect/no-detect
decision wants the mode (Session 10).