Functions of Random Variables
Suppose is a random variable whose distribution you know completely. You form a new random variable by applying some function . What is the distribution of ? This question sits at the heart of nearly every applied probability calculation. Examples include converting a uniform random number into an exponential waiting time. Or converting a normal measurement into a chi-squared statistic. Or converting a radius into an area. It is not a peripheral technical exercise. It is the mechanism by which every random-number generator on every computer produces samples from non-uniform distributions. It is also the mechanism by which statisticians derive the sampling distributions (chi-squared, , ) that underlie classical inference. The big picture is that there are exactly two systematic routes to the distribution of . They are secretly the same idea viewed at two levels of resolution. The CDF method works directly with , translating it into a statement about lying in some -dependent set. It is fully general — it works whether or not is monotonic or differentiable. The change-of-variables (Jacobian) method differentiates the CDF method's output to get a density formula directly. This comes at the price of requiring to be smooth and (locally) invertible. Almost every "trick" you will see for computing distributions of transformed variables is one of these two methods executed on a specific . This includes the probability integral transform, the derivation of the log-normal density, and the square of a normal being . This article develops both methods with full rigor. It starts from the definition of the pushforward distribution and proves the general CDF formula. It then specializes to the classical change-of-variables theorem for strictly monotonic differentiable transformations. This includes its extension to piecewise-monotonic , needed for non-injective maps like . We treat continuous random variables as the primary case, since that is where the calculus is subtle. The discrete case is a direct bookkeeping exercise mentioned only in passing. The reward for mastering this machinery is not merely computational. It is conceptual: distributions are not attached to symbols like or but to events. A transformation is really a relabeling of outcomes. Once this is internalized, the Uniform and Exponential Distributions and the Normal Distribution stop being a list of memorized formulas. They become instances of one universal principle. This principle also underlies simulation via the inverse CDF method.
- For any random variable and function , has CDF — always valid, always computable in principle.
- If is strictly increasing and differentiable with nonzero derivative, .
- The general change-of-variables formula sums over all branches of when is only piecewise monotonic (e.g. ).
- The Jacobian factor is exactly the local "stretching factor" that converts -probability-mass density into -probability-mass density.
- The probability integral transform ( is when is continuous) is the change-of-variables theorem run in reverse, and is the theoretical basis of simulation.
- Key idea: a transformation of a random variable is a relabeling of outcomes, and its distribution is obtained by pulling probability back through , either as a set (CDF method) or as a density times a local stretch factor (Jacobian method).
Where this lives today
The change-of-variables machinery for transformed random variables is used constantly across mathematics and its applications. In statistics, it derives the sampling distributions of test statistics: the square of a standard normal is (a direct instance of the piecewise-monotonic corollary above, specialized to a symmetric ), sums of such squares give , and ratios of independent chi-squared variables give the -distribution used in ANOVA. In simulation and computer graphics, the inverse CDF method (foreshadowed here) reverses the roles: given , the variable has CDF exactly , because is itself the transformation in the theorem, run through the monotonic-preimage lemma — this is precisely how software libraries generate exponential, normal, and other non-uniform random variates from a uniform random number generator. In physics, transformations of random variables appear whenever a measured quantity (energy, momentum, radius) is a nonlinear function of a fundamentally random quantity, such as converting a uniformly distributed scattering angle into a non-uniformly distributed detector position — the Jacobian factor is literally the "phase space" volume element familiar from statistical mechanics. In finance, the log-normal model for asset prices is obtained by applying to a normal random variable , an instance of the strictly-monotonic change-of-variables theorem with increasing and . In cryptography and coding theory, transformations of random bit-strings (hash outputs, error patterns) are analyzed via the discrete analogue of the pushforward construction. In machine learning, normalizing flows — a modern generative modeling technique — are built entirely on iterated applications of the multivariate change-of-variables formula, using compositions of invertible neural-network layers whose Jacobian determinants must be tracked exactly as in this article's single-variable case.
Ask the tutor: How does the single-variable change-of-variables formula generalize to a joint transformation of two or more random variables using the Jacobian determinant?
Let be a probability space and let be a random variable. Let be a Borel-measurable function. Define
Then is itself a random variable (a measurable function ), called a function of . Its distribution is the pushforward measure
and in particular its cumulative distribution function is
When is continuous with density and is, on the support of , piecewise strictly monotonic and continuously differentiable with nonvanishing derivative, is continuous (or a mixture, in degenerate cases) and its density is obtained by differentiating , as made precise in the Change of Variables theorem below.
Intuition
Think of as a machine that outputs a real number according to some law, and think of as a lens through which you view that output. You never see directly — you only see , the reading after passing through the lens. The distribution of answers: "given the probabilities governing , what probabilities govern what I actually observe?" The CDF method is the event-level answer: to know , find the set of -values that the lens maps into , and compute the -probability of that set. This works for any measurable , including non-monotonic, non-differentiable, or even discontinuous lenses — a step function, an absolute value, a clipping function. The change-of-variables method is the density-level refinement, valid when is smooth and locally invertible. Density is probability mass per unit length. If stretches a small interval around by a factor of , then the same amount of probability mass gets smeared over a longer (or shorter) interval around , so the density must be divided by that stretch factor to conserve total mass. This is exactly why the Jacobian appears: it measures how much the inverse map compresses or expands the -axis back into -space.
Theorem: The general CDF method
Let be a random variable with CDF , and let be Borel-measurable. Let . Then for every ,
In particular, if is continuous with density , then
This is a direct unwinding of the definition of pushforward measure; we spell it out to make the logical structure explicit. By definition of as a function of , for every we have . Fix . The event is, by definition of the event notation,
Now observe the set-theoretic identity
which holds because for any real number , the statement "" is by definition equivalent to ""; applying this equivalence pointwise at for each gives the claimed set equality. (This step uses only the definition of as a preimage — no probabilistic content yet.) Since is Borel-measurable, is a Borel subset of (preimage of a Borel set under a Borel map is Borel), so is a legitimate event, i.e. lies in , because is a random variable (measurable). Hence
which is the first claim. For the second claim, if is continuous with density , then by the definition of density (Radon–Nikodym derivative of with respect to Lebesgue measure), for any Borel set ,
Applying this with gives , completing the proof.
∎This theorem is completely general — it places no hypothesis on beyond measurability, which is needed merely for to be a legitimate random variable. Its cost is that can be an arbitrarily complicated set, and computing may require case analysis. The next theorem specializes to the situation where is smooth and monotonic, in which case is simply a ray, and differentiating produces a clean formula for .
Let be a strictly increasing (respectively strictly decreasing), continuous bijection between intervals , with inverse . Then for ,
Suppose is strictly increasing. If , then since is (weakly) increasing, . Conversely if , then since is strictly increasing it is injective and order-preserving with an order-preserving inverse on (a standard fact: a strictly increasing continuous bijection has a strictly increasing inverse, proved by noting inherits injectivity from bijectivity of and monotonicity from a straightforward contradiction argument — if but , applying the increasing would force , a contradiction). Applying to gives . This proves the two inclusions, hence equality, in the increasing case. The decreasing case is symmetric, with all inequalities reversed by the same argument applied to , which is increasing.
∎Let be a continuous random variable with density supported on an open interval (i.e. outside ). Let be a strictly monotonic, differentiable bijection onto an open interval , with for all . Let . Then is a continuous random variable with density
and for .
We give the proof for strictly increasing; the strictly decreasing case is obtained by an entirely parallel argument (or by applying the increasing case to , using that composing with a sign flip is itself an instance of the theorem for the linear map , which one verifies directly satisfies the conclusion).
Step 1 (differentiability of ). Since is differentiable on with everywhere, the inverse function theorem for one real variable applies: is differentiable on with
(This classical fact follows from the definition of derivative applied to the difference quotient of , using continuity of — itself guaranteed by strict monotonicity and continuity of on an interval — and the nonvanishing of .)
Step 2 (CDF of via the monotonic preimage lemma). By CDF of a transformed random variable, for ,
By the Monotonic preimage lemma (increasing case), . Since vanishes outside ,
For below (i.e. ), so ; for above , so . This confirms takes values (with probability one) in and matches the claim that vanishes outside .
Step 3 (differentiate). For in the interior of , is a composition of the differentiable function with . We use that is differentiable at every point where is continuous, with there — this is the Fundamental Theorem of Calculus applied to the definition , valid at continuity points of , which we assume (as is standard for densities arising in this theorem; densities are only defined up to null sets and we work at their continuity points). By the chain rule,
Since is strictly increasing, (as everywhere on for an increasing differentiable bijection — if at some point, would be locally decreasing near , contradicting strict monotonicity globally combined with the intermediate value theorem applied to , which cannot change sign without vanishing since throughout), so , giving exactly
Step 4 (decreasing case, sign check). If is strictly decreasing, the same Step 2 argument with the decreasing case of the monotonic preimage lemma gives (using that is continuous so single points have probability zero, hence ). Differentiating,
Here throughout (by the same sign-constancy argument as above, applied to the decreasing case), so , hence , and again
Both monotonicity cases yield the identical stated formula, completing the proof.
∎Let be continuous with density supported on , and let be such that decomposes into finitely (or countably) many disjoint open intervals (with a Lebesgue-null leftover set of "boundary" points) on each of which restricts to a strictly monotonic, differentiable bijection with nonvanishing derivative. Then has density
The boundary set is Lebesgue-null by hypothesis, so and we may ignore it: . The events partition up to a null set, so
using countable additivity of over the disjoint events — this is a direct application of countable additivity of probability measures to a countable disjoint union, which is part of the axiomatic definition of , hence not circular. On , agrees with the strictly monotonic bijection , so by the Monotonic preimage lemma, equals or according to whether increases or decreases (and is empty if ). Each summand is therefore , and differentiating the resulting sum termwise (justified because it is a finite, or locally finite, sum of differentiable functions of ) applies the single-branch change-of-variables theorem to each term, yielding the stated sum.
∎Worked examples
Example 1 (asymmetric linear-then-nonlinear transformation, using the CDF method to sanity-check the Jacobian method). Let with , so for and for . Let
an asymmetric affine transformation (not just a rescaling): it shifts by , flips sign, and stretches by . Find . CDF method. Since a.s., a.s. For ,
For , (in fact this formula extended continuously gives at , consistent). Differentiating for :
and for . Jacobian method, as a check. Here is strictly decreasing on , with inverse and , so . The range is . By the theorem,
matching the CDF-method answer exactly. As a numerical check, at : , so ; total mass check by substitution, as it must.
Example 2 (non-monotonic transformation, needing the piecewise-monotonic corollary). Let (mean , variance , so ), with density
Let . Since is not centered at , this is a genuinely asymmetric instance of squaring — the two branches contribute unequally. Find for . Here is not globally monotonic on , but splits into two strictly monotonic branches: with strictly decreasing, inverse ; and with strictly increasing, inverse . Both map onto . In each case . By the Piecewise-monotonic change of variables corollary, for :
Plugging in :
Note the two exponential terms are not equal (unlike the standard-normal case , where they'd coincide and give the familiar density) — this asymmetry is exactly the point of choosing mean . As a numerical spot check at (so ): the two exponents are and , giving
One can confirm this is sensible: since dominates whenever is close to the mean (as here), the "positive branch" contributes the bulk of the density, illustrating exactly why the naive shortcut of doubling one branch (valid only when is symmetric about ) would be wrong here.
Consider , so for , and let
This is a strictly increasing, continuous bijection from onto — monotonic, so the hypotheses of the general monotonic-preimage lemma still apply and the CDF method still works perfectly. But vanishes at , violating the "nonvanishing derivative" hypothesis of the change-of-variables theorem at that single point. Let us see what breaks if we apply the density formula carelessly. The inverse is , with derivative , which blows up as (it is undefined at and unbounded near it), even though itself is perfectly well-behaved and certainly has a legitimate, bounded density. Applying the formula naively gives
which integrates to over (one can check ) and is in fact the correct answer here — because even though blows up at the single point , it remains integrable, and the derivation of in Step 2 of the theorem's proof only used monotonicity, not differentiability. So this particular case survives. The real danger surfaces when the derivative vanishes on a whole interval or the map fails to be injective near the bad point. Take instead
which satisfies with equality at isolated points , and is still strictly increasing overall (since vanishes only at isolated points, not on an interval, remains injective) — this again survives, illustrating that isolated zeros of are a genuine edge case but not always fatal. The hypothesis truly bites when is not injective near a critical point. Take near but now suppose we (incorrectly) tried to treat it as if a single global inverse existed and used the single-branch theorem across an interval straddling , e.g. naively writing for without splitting into branches. Since maps both and to the same , the single-branch formula
integrates to : it loses half the mass, precisely the mass belonging to the branch that the single global inverse formula silently discarded. This is the concrete failure mode: dropping monotonicity (using a formula built for one monotonic branch when is genuinely two-to-one) produces a function that fails even to integrate to , i.e. it is not a valid density at all. The fix is exactly the Piecewise-monotonic change of variables corollary, which restores the missing branch and gives the correct total mass , as verified in Example 2 above.
Scope, edge cases & common traps
| Situation | Correct tool | Common error |
|---|---|---|
| strictly monotonic, differentiable, | Single-branch Jacobian formula | Forgetting the absolute value on , giving negative "density" for decreasing |
| piecewise monotonic (e.g. , , on ) | Sum over branches (corollary) | Applying single-branch formula and silently losing mass from other branches |
| has isolated critical points but stays injective | Jacobian formula still applies away from critical points; density may blow up (integrably) there | Concluding the theorem "fails" whenever anywhere, even at isolated non-flat points |
| not injective and not smooth (e.g. discontinuous, or constant on an interval) | CDF method only | Trying to force a Jacobian formula where no local inverse derivative exists |
| discrete | Direct pushforward: | Attempting to use a density-based Jacobian formula on a discrete variable |
| continuous but not differentiable at isolated points (e.g. ) | CDF method, or piecewise Jacobian avoiding the kink | Differentiating through the kink without checking one-sided derivatives agree |
The mathematician behind it
The change-of-variables technique for densities is a direct descendant of the classical change-of-variables formula in multivariable calculus (the Jacobian determinant rule), transplanted into probability theory as measure-theoretic probability matured in the early twentieth century. No single person is credited with "inventing" the technique for random variables — it is a natural corollary of the measure-theoretic framework for probability — but its systematic, rigorous formulation is inseparable from the axiomatization of probability theory due to Andrei Kolmogorov, whose 1933 monograph Grundbegriffe der Wahrscheinlichkeitsrechnung placed random variables on the same footing as measurable functions in analysis, making constructions like pushforward measures (and hence the CDF method) precise objects rather than heuristic manipulations.
Origins · 1 minAndrei Nikolaevich Kolmogorov and how this was discovered
Kolmogorov founded modern probability theory on measure-theoretic foundations, defining random variables as measurable functions on an abstract probability space. This framework is exactly what makes the pushforward construction rigorous rather than a computational trick, and it underlies every result in this article.
Why do we need to be strictly monotonic for the Jacobian formula, rather than just differentiable?
Strict monotonicity guarantees has a well-defined, single-valued inverse on its range, so that the preimage is a single ray or , as shown in the monotonic preimage lemma. Without monotonicity, may not exist as a function (multiple can map to the same ), and the preimage set can be a complicated union of intervals whose measure cannot be written as a single evaluation of . In that case you must either split the domain into monotonic pieces and sum the branch contributions (the piecewise corollary), or fall back on the fully general CDF method, which never assumes monotonicity at all.
Does the change-of-variables formula work for discrete random variables?
Not in the density form given here, but a direct analogue holds. If is discrete with pmf and is any function, then is discrete with pmf
which is simply the discrete pushforward and requires no monotonicity or differentiability at all, since there are no densities or Jacobians involved — probability mass just gets regrouped according to which 's collide under . The CDF method of this article specializes correctly to this case, since remains valid verbatim for discrete .
What is the probability integral transform, and how does it relate to this article?
If is a continuous random variable with strictly increasing, continuous CDF , then is exactly -distributed. This is a direct instance of the change-of-variables theorem with itself (which is strictly increasing and differentiable with derivative ), since the resulting density works out to the constant on . Running this transformation in reverse — starting from and setting — is the inverse CDF method used to simulate any target distribution from a source of uniform random numbers, which this article foreshadows as its natural next application.
Can fail to be injective yet still yield a computable density for ?
Yes, as long as is piecewise monotonic with finitely (or countably) many differentiable, invertible branches on which , as in the piecewise-monotonic corollary. The density of at a point is then the sum, over every branch whose range contains , of that branch's contribution . This is exactly how one derives, for instance, the density of or (on an interval covering more than one monotonic piece) from a known density .
Why does the CDF method always work while the Jacobian method sometimes fails?
The CDF method only uses the definition of the pushforward measure and the algebraic fact that , which holds for any measurable with no smoothness assumption whatsoever. The Jacobian method is a derivative of that same CDF, obtained via the chain rule, and the chain rule itself demands differentiability of — which in turn demands local invertibility and a nonvanishing derivative of . When fails to be smooth or invertible, may still be perfectly computable via the CDF method (perhaps not differentiable everywhere, or requiring case analysis of ), but the shortcut differentiation formula simply has no valid chain rule to appeal to.
How does this generalize to functions of several random variables, e.g. ?
The same two-method dichotomy generalizes verbatim to higher dimensions. The CDF method still computes as , a region-of-the-plane calculation using the joint density. The Jacobian method generalizes to the multivariate change-of-variables formula: if is a differentiable bijection between open regions with nonvanishing Jacobian determinant, the joint density transforms by multiplying by the absolute value of the Jacobian determinant of the inverse map, exactly mirroring the single-variable absolute-derivative factor here. This multivariate extension is the direct machinery behind deriving distributions like the -distribution and behind normalizing flows in modern generative modeling.