Movement II: One Random Variable
EE 520: Random Processes (Fall 2026). Instructor: John Lipor.
Every homework simulation so far has quietly called a library
sampler: a line like np.random. laplace or
np.random.exponential returns a number, and you have
trusted it. What actually happened inside that call? By the end of today
you could have written the sampler yourself, from a single uniform
random number and a formula you will derive. Getting there means
answering the more basic question first: if
is random and you push it through a function to form
,
what is the distribution of
?
Every instrument is such a function (a sensor maps a physical quantity
to a voltage, a detector maps a field amplitude to a power), so this is
the mathematics of modeling measurement itself. We will find the density
of
,
discover why the formula carries a derivative, turn that machinery
around to build samplers, and close by computing something that sounds
impossible: the value of a measurement before you take it.
The reliable tool for a function of a random variable is the CDF, because it turns a statement about into a statement about , where we know the distribution. For , and now everything depends on solving the inequality for . When is strictly increasing this is immediate: exactly when , so , and differentiating gives the density. This is worth stating as a theorem.
Theorem 1 (Monotone change of variables). Let be a continuous random variable with density , and let be strictly monotone and differentiable on the support of , with inverse . Then has density for in the range of , and otherwise.
Proof. Take strictly increasing first. Then is increasing, and from [eq:cdfpushforward], Differentiate in by the chain rule: and the derivative is positive, so it equals its own absolute value. If instead is strictly decreasing, then means , so ; differentiating introduces a minus sign, and in this case, so the two signs cancel and the result is again [eq:cov] with the absolute value. The absolute value unifies both cases. ◻
Why is there a derivative in the formula?. A density is a rate, probability per unit length, and stretches lengths. A sliver of width at carries mass ; the map sends it to a sliver at whose width is , wider or narrower depending on the local slope of . Probability mass is conserved (the same points, relabeled), but it is now spread over a different length, so the density must be rescaled by the reciprocal of that stretch factor, which is exactly . The derivative is not a technicality; it is the bookkeeping that keeps total probability equal to one after distorts the axis.
Figure 1 makes this concrete, using the example we are about to work in full. Follow sliver A of width on the -axis up to the curve and across to the -axis. Where is flat it lands in a narrower interval (width ), so the same mass piles up taller. Sliver B has the same width in , but is steep there and it lands in an interval of width , so its mass is spread thinner. Each sliver carries the same probability on both axes (about for A and for B); only its width, and hence its height, changes.
Here is Theorem 1 doing real work. A narrowband wireless channel delivers a complex gain whose magnitude, the envelope, is the Rayleigh random variable with CDF and density The receiver does not act on the envelope but on the instantaneous power it delivers, . What is the distribution of ?
On the support the map is strictly increasing, and that monotonicity is exactly the hypothesis of Theorem 1, which is why we may use it here and could not for ranging over all of . Its inverse and derivative are Substituting into [eq:cov], The from the density and the from the derivative cancel, and what remains is an exponential density with rate , hence mean . In words: a Rayleigh envelope produces exponential power. This pairing is not a coincidence of this problem; it reappears in every fading-channel course you will take, and it is worth committing to memory.
Now compute an outage probability (the chance the delivered power falls below a threshold ) two ways, to make a methodological point. The first way transforms the event back to the envelope domain and uses the CDF we already had: The second way integrates the density we just derived: Same answer, of course, but the first route never needed at all: it rewrote the question about as a question about and read off a CDF we were handed. That is the general lesson.
Transform the event, not the density. Whenever you can, rewrite a probability about as a probability about and evaluate it with . Deriving the full density is more work and more error-prone (it is where the stray derivative gets dropped), and you often do not need it. Reach for the change-of-variables density formula only when you actually need the density of as a function. Otherwise, transform the event.
Pitfall. Two errors sink most change-of-variables computations. The first is dropping the derivative: writing and forgetting the factor . Catch it by dimensional analysis: must have units of , and only the derivative factor supplies the conversion, so an answer missing it is dimensionally wrong before it is numerically wrong, and “it integrates to one” is not a real check unless you actually verify it. The second is applying [eq:cov] to a non-monotone : the formula requires strict monotonicity on the support so that is single-valued, and we will simply never need the general case. When is not monotone, return to the CDF and solve by hand.
The same maneuver, applied to the map with a Gaussian , produces the log-normal shadowing model that describes slow signal fading behind obstacles. That map is monotone too, so Theorem 1 applies verbatim: you will carry out the derivation, and the corresponding two-way outage computation, in HW3.
Theorem 1 is not a museum piece. The change-of-variables formula is the entire probabilistic content of normalizing flows, a family of modern generative models that build a complicated density by pushing a simple one (a Gaussian) through a learned invertible map and accounting for the stretch with exactly the derivative factor in [eq:cov]. The idea is the one you just learned. Its differentiable-sampling cousin is the reparameterization trick behind variational autoencoders: instead of sampling directly, write so that the randomness sits in a fixed and the parameters enter through a smooth, differentiable map (in a VAE, and are themselves outputs of a network, so gradients flow through them to its weights). A student who can say why there is a derivative in the density formula owns these ideas; a student who cannot will use those tools as incantations.
We now run the machinery backwards. A computer’s random-number generator produces and essentially nothing else; every other distribution must be manufactured from it. The change-of-variables idea tells us how.
Proposition 1 (Inverse-CDF sampling). Let be a continuous, strictly increasing CDF with inverse , and let . Then the random variable has CDF .
Proof. Using that is increasing (so ) and that is uniform (so for ), Thus has exactly the CDF , as claimed. ◻
The recipe. To draw a sample from any distribution with an invertible CDF : draw , then return . Feeding uniform draws through reproduces exactly. This one line is the secret inside a great many library samplers.
Make it concrete with the exponential, whose draws you have been
making since Session 6. Its CDF is
.
Set
and solve for
:
Two lines, and the
mystery is gone: np.random.exponential is
with a uniform
underneath. (One often sees
instead; since
and
have the same uniform distribution, either is correct.)
Remark 1. Inverse sampling plus a uniform generator is the whole secret of a great many library samplers. When has no closed-form inverse, other constructions (rejection sampling, among them) take over, but those are beyond our scope, and a single uniform through suffices for every sampler this course needs.
The envelope-to-power example gave you a Rayleigh ; HW3 asks you to close the loop and build the Rayleigh sampler your simulator has quietly been using, by inverting its CDF exactly as we just inverted the exponential’s.
Session 6 met the Gumbel as the limit of the last of many exponential alarms. Apply the inverse-CDF recipe to the standard Gumbel CDF . Set and solve for : So is a standard Gumbel draw. Look at the inner piece: is exactly the exponential sampler we just built (with , and with in place of , which is equally valid). So a Gumbel is the negative logarithm of an exponential: Confirm this directly, working with the CDF as in the proof of Theorem 1. The map is strictly decreasing, so the inequality flips: which is the standard Gumbel CDF.
This explains the parallel noted in Session 6, where minima of exponentials added their rates and maxima of Gumbels added their weights . Shifting by turns into a recipe for every Gumbel: if , then has the distribution. Writing , the variable is exponential with rate . Now take independent and generate each as from its own independent . This loses nothing, since the distribution of depends only on the distributions of the independent . Because is decreasing, it turns the maximum of Gumbels into the minimum of exponentials: and the minimum of independent exponentials with rates is exponential with rate . Undoing the logarithm gives , a second proof of Session 6’s max-stability proposition. “Rates add” and “’s add” are the same fact seen through a decreasing monotone map.
Keep in mind for this session’s AI corner. The corner samples a token by cutting into segments; Session 9 will show a second way to make the same draw, using one Gumbel per token and an argmax.
Session 3 turned a belief into an action by maximizing expected utility: with a finite action set and utility , the best action under the current belief earns the value of acting now. But we usually have the option to observe something first (run a sensor, buy a measurement ) and only then act, choosing the best action under the posterior belief given . Since we do not yet know what will be, we average that improved decision over the possible observations: The improvement buys over is worth naming.
Definition 1 (Value of a measurement). The value of a measurement is the expected gain in achievable utility from observing before acting, versus acting immediately.
Proposition 2 (Information never hurts in expectation). .
Proof. For any fixed action , the tower property gives . Taking the best fixed action on the left and comparing, where the inequality is the Jensen-flavored fact that a max of averages is at most the average of maxes: committing to one action in advance can never beat choosing the best action separately in each -world. Hence . ◻
The proposition says information is never harmful on average, but it earns its keep only if its value clears its price. A measurement that costs is worth taking precisely when ; otherwise act now and save the cost. HW3 makes that comparison; worked example (b) below asks what happens to when the reading is degraded on its way to us.
Inverse-CDF sampling turns a uniform into any distribution we like. Run it the other way. Take a continuous random variable with CDF and form the new random variable , the CDF evaluated at its own random argument. What is the distribution of ? The tempting guess is that it depends on : a skewed should give a skewed , a heavy-tailed something else again.
Proposition 3 (Probability integral transform). Let have a CDF that is continuous and strictly increasing on the support of . Then is , whatever the distribution of .
Proof. takes values in . For , transform the event as in the proof of Proposition 1, now in the other direction: since is increasing, exactly when , so which is the CDF. ◻
The guess fails for a reason Theorem 1 makes visible. The map is increasing with , so at , and In the language of Figure 1: is steepest exactly where is most likely, so it stretches the dense regions of and squeezes the sparse ones by precisely the amount that flattens the density. Uniforms in, any distribution out (Proposition 1); any continuous distribution in, uniforms out (Proposition 3).
The hypothesis matters. Let . Then and , so equals with probability and equals with probability : two atoms, nothing like a uniform. A jump in becomes an atom of , which is why the proposition needs continuous.
A weather forecaster, or a machine-learning model that reports uncertainty, issues a predictive CDF for each outcome before it is observed. If the model is right, is the true CDF of , so by Proposition 3 each is uniform, and a histogram of the over many forecasts should be flat. The check needs only the outcomes and the model’s own CDFs, never the true distribution. Departures from flatness diagnose the error. Suppose the truth is but the model claims , so . Transforming the event once more, An overconfident model, with (error bars half as wide as they should be), puts of the outcomes in the bottom tenth of its predictive distribution and, by symmetry, another in the top tenth. Over half the outcomes land in the outer , and the histogram is U-shaped. An underconfident model, with , puts only about in each outer tenth and in the middle fifth: a hump. A flat histogram is the first test that a model’s stated uncertainty must pass before anyone should act on it.
Return to the decision layer with a concrete problem. A target is either present () or absent (), and we must declare one, with utilities
| Action | (present) | (absent) |
|---|---|---|
| Declare present | (false alarm) | |
| Declare absent | (miss) |
A sensor reading obeys and . At prior , working through the definitions gives (declare present without looking) and .
Now suppose the reading does not reach us directly. It is relayed over a link that flips the bit with probability , independently of everything else, and we see only the received bit . We know , so we know ’s likelihoods exactly: by total probability over , A natural hope is that Bayes’ rule with these correct likelihoods undoes the damage, or at least that some clever enough rule for acting on recovers what the link took. It cannot.
Proposition 4 (Noise cannot add value). Let be obtained from by flipping it with probability , independently of . Then for every prior and every utility, .
Proof. Think in rules. A decision rule assigns an action to each possible reading. Choosing the best action separately for each reading, as does, is the same as choosing the best rule, because and each term can be maximized on its own. So , and likewise for .
Fix any rule for acting on . Condition on whether the link flipped. The flip is independent of : with probability we have , and with probability we have , so Both and are rules that act on , so each expectation on the right is at most , and so is their average. Maximizing over gives . The act-now value does not involve the measurement, so subtracting it from both sides gives the claim. ◻
This is the argument behind Proposition 2 again: a rule acting on is an average of rules acting on , and an average cannot beat the best. In fact Proposition 2 is the special case . Then is a fair coin flip independent of , observing it leaves the prior unchanged, so , and Proposition 4 reads .
The loss is fast. At prior , the value of the relayed reading is
| Flip probability | ||||
|---|---|---|---|---|
A link that delivers the right bit of the time leaves less than a tenth of the reading’s value. Knowing exactly does not help: Bayes’ rule with ’s likelihoods extracts everything contains, and the loss is in , not in the inference.
Deterministic processing is the easier case. If for a fixed function (quantizing a reading, compressing it, or reducing it to a summary before the decision is made), then any rule acting on is already a rule acting on , namely , so with no averaging needed. Noise or processing, the conclusion is the same: what happens to a reading between the sensor and the decision can lose value but never create it.
Posterior Action. With , the receiver does everything right: it runs Bayes’ rule with ’s own likelihoods, getting and , and declares present exactly when the posterior exceeds , the point where the two actions break even. That is the best anyone holding can do. But the clean reading would have given posteriors and , further from the threshold on both sides, and acting on is right more often than acting on . The action follows the posterior, the posterior can only be as decisive as the evidence, and the value lost on the link is lost for good.
One question to carry out of the room, asked but deliberately left unanswered here. For the clean sensor , compute for a range of priors , from near to near , and plot it against the prior. The curve has the shape of Figure 2. Where does it peak, and where does it fall to zero? Think about what a measurement can and cannot do for you when you are already almost sure, and settle the question in HW3.
AI corner: how a model picks a token (sampling and temperature). AI corner 1 said a language model is, mathematically, a conditional pmf; today we learned how machines draw from distributions, so put the two together. When a language model emits a token it samples from a categorical pmf over its finite vocabulary, the finite-alphabet cousin of today’s inverse-CDF sampler. Partition into segments whose lengths are the cumulative token probabilities, draw one , and the segment it lands in names the emitted token. Before drawing, a temperature reshapes the pmf from scores (“logits”) via . With logits , the top token has probability at , at , and at : as the pmf collapses onto the (deterministic, “greedy” decoding), while large flattens it toward uniform (diverse, but more error-prone). Temperature is a knob on the pmf, nothing more mysterious. So-called top- (“nucleus”) sampling is even more familiar: keep the smallest set of tokens whose cumulative probability reaches , renormalize, and sample: literally Session 1’s restrict-and-renormalize.
Work these in class.
(Monotone change of variables.) Let
and
.
Show
is strictly monotone on
,
then use Theorem 1 to find
and its support.
Answer:
is strictly decreasing, with
and
.
Since
on
and
ranges over
,
on
(check:
).
(Inverse-CDF sampling.) A random variable has CDF
on
.
Write the one-line rule that turns a uniform draw
into a sample of
.
Answer: invert
to get
;
return the square root of a uniform draw.
(Value of a measurement, conceptual.) In one or two
sentences, explain why
always, yet a rational agent may still decline to measure.
Answer: By Proposition 2 the
expected best-case utility can only rise (or stay flat) once you may
adapt the action to the reading, so
;
but the measurement has a cost
,
and when
the information is not worth its price, so acting now is
optimal.
The course thesis asks what is uncertain, what is observed, and how observation should change belief and action; this session worked the machinery of observation itself. Pushing a random variable through a monotone function gave the density of , and the derivative in that formula turned out to be honest bookkeeping: a density is a rate, stretches lengths, and mass (not density) is what is conserved. Running the same idea backwards produced inverse-CDF sampling, the one-line reason your simulators work at all (the Gumbel sampler even revealed a Gumbel to be the negative logarithm of an exponential). Run backwards once more, it showed that every continuous variable pushed through its own CDF is uniform, which is how one checks whether a model’s stated uncertainty is honest. The same change-of-variables identity is the whole probabilistic content of the generative models students meet later. Then the decision layer returned: a measurement’s worth is , computable before the measurement is taken, never negative in expectation, never increased by noise or processing between the sensor and the decision, and worth paying for only when it clears its cost. Next session we take the decisive step to two random variables at once (joint distributions, marginals, and conditionals), where Bayes’ rule returns yet again, now wearing densities.
In the change-of-variables formula, why must
carry the factor
?
Give the units-based reason.
Answer:
is a density, with units of
;
has units
,
and
supplies the
conversion so the units come out right. Physically,
stretches lengths, so the density must be rescaled by the reciprocal
stretch factor to conserve probability mass.
You have
and want a sample from a distribution with continuous, strictly
increasing CDF
.
What do you return, and why does it work?
Answer: return
;
then
, so
has CDF
.
A colleague says “a measurement can only help, so always
measure.” Where is the error?
Answer:
holds only for the expected utility and ignores cost; measuring
is optimal only when
exceeds the measurement’s cost, and it can also fail to help on a
particular reading even when it helps on average.