Functions of Random Variables

Suppose XX is a random variable whose distribution you know completely. You form a new random variable Y=g(X)Y = g(X) by applying some function gg. What is the distribution of YY? 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, tt, FF) that underlie classical inference. The big picture is that there are exactly two systematic routes to the distribution of Y=g(X)Y=g(X). They are secretly the same idea viewed at two levels of resolution. The CDF method works directly with P(Y≤y)P(Y \le y), translating it into a statement about XX lying in some gg-dependent set. It is fully general — it works whether or not gg 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 gg 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 gg. This includes the probability integral transform, the derivation of the log-normal density, and the square of a normal being χ12\chi^2_1. 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 gg, needed for non-injective maps like g(x)=x2g(x)=x^2. 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 XX or YY but to events. A transformation gg 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.

Key takeaways
  • For any random variable XX and function gg, Y=g(X)Y=g(X) has CDF FY(y)=P(X∈g−1((−∞,y]))F_Y(y) = P(X \in g^{-1}((-\infty,y])) — always valid, always computable in principle.
  • If gg is strictly increasing and differentiable with nonzero derivative, fY(y)=fX(g−1(y)) ∣(g−1)′(y)∣f_Y(y) = f_X(g^{-1}(y))\,|(g^{-1})'(y)|.
  • The general change-of-variables formula sums over all branches of g−1g^{-1} when gg is only piecewise monotonic (e.g. g(x)=x2g(x)=x^2).
  • The Jacobian factor ∣(g−1)′(y)∣|(g^{-1})'(y)| is exactly the local "stretching factor" that converts XX-probability-mass density into YY-probability-mass density.
  • The probability integral transform (Y=FX(X)Y = F_X(X) is Uniform(0,1)\mathrm{Uniform}(0,1) when FXF_X 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 g−1g^{-1}, 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 χ12\chi^2_1 (a direct instance of the piecewise-monotonic corollary above, specialized to a symmetric XX), sums of such squares give χn2\chi^2_n, and ratios of independent chi-squared variables give the FF-distribution used in ANOVA. In simulation and computer graphics, the inverse CDF method (foreshadowed here) reverses the roles: given U∼Uniform(0,1)U\sim \mathrm{Uniform}(0,1), the variable X=FX−1(U)X = F_X^{-1}(U) has CDF exactly FXF_X, because FX−1F_X^{-1} is itself the transformation gg 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 g(x)=exg(x)=e^x to a normal random variable XX, an instance of the strictly-monotonic change-of-variables theorem with gg increasing and g−1(y)=ln⁡yg^{-1}(y)=\ln y. 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?

DefinitionFunction of a random variable and its induced distribution

Let (Ω,F,P)(\Omega,\mathcal F, P) be a probability space and let X:Ω→RX:\Omega\to\mathbb R be a random variable. Let g:R→Rg:\mathbb R\to\mathbb R be a Borel-measurable function. Define

Y(ω):=g(X(ω)),ω∈Ω.Y(\omega) := g(X(\omega)), \qquad \omega \in \Omega.

Then YY is itself a random variable (a measurable function Ω→R\Omega \to \mathbb R), called a function of XX. Its distribution is the pushforward measure

PY(B):=P(Y∈B)=P(X∈g−1(B)),B⊆R Borel,P_Y(B) := P(Y \in B) = P\big(X \in g^{-1}(B)\big), \qquad B \subseteq \mathbb R \text{ Borel},

and in particular its cumulative distribution function is

FY(y):=P(Y≤y)=P(X∈g−1((−∞,y])),y∈R.F_Y(y) := P(Y \le y) = P\big(X \in g^{-1}((-\infty, y])\big), \qquad y \in \mathbb R.

When XX is continuous with density fXf_X and gg is, on the support of XX, piecewise strictly monotonic and continuously differentiable with nonvanishing derivative, YY is continuous (or a mixture, in degenerate cases) and its density fYf_Y is obtained by differentiating FYF_Y, as made precise in the Change of Variables theorem below.

Intuition

Think of XX as a machine that outputs a real number according to some law, and think of gg as a lens through which you view that output. You never see XX directly — you only see Y=g(X)Y = g(X), the reading after passing through the lens. The distribution of YY answers: "given the probabilities governing XX, what probabilities govern what I actually observe?" The CDF method is the event-level answer: to know P(Y≤y)P(Y \le y), find the set of XX-values that the lens maps into (−∞,y](-\infty, y], and compute the XX-probability of that set. This works for any measurable gg, 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 gg is smooth and locally invertible. Density is probability mass per unit length. If gg stretches a small interval around xx by a factor of ∣g′(x)∣|g'(x)|, then the same amount of probability mass gets smeared over a longer (or shorter) interval around y=g(x)y = g(x), so the density must be divided by that stretch factor to conserve total mass. This is exactly why the Jacobian ∣(g−1)′(y)∣|(g^{-1})'(y)| appears: it measures how much the inverse map compresses or expands the yy-axis back into xx-space.

Figure
Stretching intuition: a small interval near x0x_0 maps to an interval near y0=g(x0)y_0=g(x_0) of different length, so density rescales by ∣g′(x0)∣−1|g'(x_0)|^{-1}
x-axis (domain of X) Δx x₀ x₀+Δx g y-axis (range, Y=g(X)) Δy = g'(x₀)Δx (large) y₀ y₀+Δy mass ≈ f_X(x₀)Δx same mass, spread over larger Δy so f_Y(y₀) = f_X(x₀)/|g'(x₀)| is smaller

Theorem: The general CDF method

TheoremCDF of a transformed random variable

Let XX be a random variable with CDF FXF_X, and let g:R→Rg:\mathbb R \to \mathbb R be Borel-measurable. Let Y=g(X)Y = g(X). Then for every y∈Ry \in \mathbb R,

FY(y)=P(X∈Ay),Ay:={x∈R:g(x)≤y}=g−1((−∞,y]).F_Y(y) = P\big(X \in A_y\big), \qquad A_y := \{x \in \mathbb R : g(x) \le y\} = g^{-1}\big((-\infty,y]\big).

In particular, if XX is continuous with density fXf_X, then

FY(y)=∫AyfX(x) dx.F_Y(y) = \int_{A_y} f_X(x)\,dx.
Proof

This is a direct unwinding of the definition of pushforward measure; we spell it out to make the logical structure explicit. By definition of YY as a function of XX, for every ω∈Ω\omega\in\Omega we have Y(ω)=g(X(ω))Y(\omega) = g(X(\omega)). Fix y∈Ry\in\mathbb R. The event {Y≤y}\{Y \le y\} is, by definition of the event notation,

{ω∈Ω:Y(ω)≤y}={ω∈Ω:g(X(ω))≤y}.\{\omega \in \Omega : Y(\omega) \le y\} = \{\omega \in \Omega: g(X(\omega)) \le y\}.

Now observe the set-theoretic identity

{ω:g(X(ω))≤y}={ω:X(ω)∈Ay},\{\omega : g(X(\omega)) \le y\} = \{\omega : X(\omega) \in A_y\},

which holds because for any real number xx, the statement "g(x)≤yg(x)\le y" is by definition equivalent to "x∈Ayx \in A_y"; applying this equivalence pointwise at x=X(ω)x = X(\omega) for each ω\omega gives the claimed set equality. (This step uses only the definition of AyA_y as a preimage — no probabilistic content yet.) Since gg is Borel-measurable, Ay=g−1((−∞,y])A_y = g^{-1}((-\infty,y]) is a Borel subset of R\mathbb R (preimage of a Borel set under a Borel map is Borel), so {X∈Ay}\{X \in A_y\} is a legitimate event, i.e. lies in F\mathcal F, because XX is a random variable (measurable). Hence

FY(y)=P(Y≤y)=P({ω:X(ω)∈Ay})=P(X∈Ay),F_Y(y) = P(Y\le y) = P(\{\omega: X(\omega)\in A_y\}) = P(X \in A_y),

which is the first claim. For the second claim, if XX is continuous with density fXf_X, then by the definition of density (Radon–Nikodym derivative of PXP_X with respect to Lebesgue measure), for any Borel set AA,

P(X∈A)=∫AfX(x) dx.P(X \in A) = \int_A f_X(x)\,dx.

Applying this with A=AyA = A_y gives FY(y)=∫AyfX(x) dxF_Y(y) = \int_{A_y} f_X(x)\,dx, completing the proof. ■\blacksquare

∎

This theorem is completely general — it places no hypothesis on gg beyond measurability, which is needed merely for YY to be a legitimate random variable. Its cost is that AyA_y can be an arbitrarily complicated set, and computing ∫AyfX\int_{A_y} f_X may require case analysis. The next theorem specializes to the situation where gg is smooth and monotonic, in which case AyA_y is simply a ray, and differentiating FYF_Y produces a clean formula for fYf_Y.

LemmaMonotonic preimage lemma

Let g:I→Jg:I \to J be a strictly increasing (respectively strictly decreasing), continuous bijection between intervals I,J⊆RI, J \subseteq \mathbb R, with inverse g−1:J→Ig^{-1}:J\to I. Then for y∈Jy \in J,

{x∈I:g(x)≤y}={x∈I:x≤g−1(y)}(increasing case),\{x \in I : g(x) \le y\} = \{x \in I : x \le g^{-1}(y)\} \quad \text{(increasing case)},
{x∈I:g(x)≤y}={x∈I:x≥g−1(y)}(decreasing case).\{x \in I: g(x)\le y\} = \{x \in I : x \ge g^{-1}(y)\} \quad \text{(decreasing case)}.
Proof

Suppose gg is strictly increasing. If x≤g−1(y)x \le g^{-1}(y), then since gg is (weakly) increasing, g(x)≤g(g−1(y))=yg(x) \le g(g^{-1}(y)) = y. Conversely if g(x)≤y=g(g−1(y))g(x) \le y = g(g^{-1}(y)), then since gg is strictly increasing it is injective and order-preserving with an order-preserving inverse on JJ (a standard fact: a strictly increasing continuous bijection has a strictly increasing inverse, proved by noting g−1g^{-1} inherits injectivity from bijectivity of gg and monotonicity from a straightforward contradiction argument — if u<vu<v but g−1(u)≥g−1(v)g^{-1}(u)\ge g^{-1}(v), applying the increasing gg would force u≥vu \ge v, a contradiction). Applying g−1g^{-1} to g(x)≤yg(x)\le y gives x≤g−1(y)x \le g^{-1}(y). 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 −g-g, which is increasing. ■\blacksquare

∎
TheoremChange of variables for a strictly monotonic transformation

Let XX be a continuous random variable with density fXf_X supported on an open interval I⊆RI \subseteq \mathbb R (i.e. fX=0f_X = 0 outside II). Let g:I→Jg: I \to J be a strictly monotonic, differentiable bijection onto an open interval JJ, with g′(x)≠0g'(x) \neq 0 for all x∈Ix \in I. Let Y=g(X)Y = g(X). Then YY is a continuous random variable with density

fY(y)=fX(g−1(y)) ∣ddyg−1(y)∣,y∈J,f_Y(y) = f_X\big(g^{-1}(y)\big)\, \left| \frac{d}{dy} g^{-1}(y) \right|, \qquad y \in J,

and fY(y)=0f_Y(y) = 0 for y∉Jy \notin J.

Proof

We give the proof for gg strictly increasing; the strictly decreasing case is obtained by an entirely parallel argument (or by applying the increasing case to −g-g, using that composing with a sign flip is itself an instance of the theorem for the linear map x↦−xx\mapsto -x, which one verifies directly satisfies the conclusion).

Step 1 (differentiability of g−1g^{-1}). Since gg is differentiable on II with g′(x)≠0g'(x) \ne 0 everywhere, the inverse function theorem for one real variable applies: g−1g^{-1} is differentiable on JJ with

(g−1)′(y)=1g′(g−1(y))for all y∈J.(g^{-1})'(y) = \frac{1}{g'(g^{-1}(y))} \quad \text{for all } y \in J.

(This classical fact follows from the definition of derivative applied to the difference quotient of g−1g^{-1}, using continuity of g−1g^{-1} — itself guaranteed by strict monotonicity and continuity of gg on an interval — and the nonvanishing of g′g'.)

Step 2 (CDF of YY via the monotonic preimage lemma). By CDF of a transformed random variable, for y∈Jy \in J,

FY(y)=P(X∈Ay),Ay={x∈I:g(x)≤y}.F_Y(y) = P(X \in A_y), \qquad A_y = \{x \in I : g(x) \le y\}.

By the Monotonic preimage lemma (increasing case), Ay={x∈I:x≤g−1(y)}=I∩(−∞,g−1(y)]A_y = \{x \in I: x \le g^{-1}(y)\} = I \cap (-\infty, g^{-1}(y)]. Since fXf_X vanishes outside II,

FY(y)=∫AyfX(x) dx=∫−∞g−1(y)fX(x) dx=FX(g−1(y)).F_Y(y) = \int_{A_y} f_X(x)\,dx = \int_{-\infty}^{g^{-1}(y)} f_X(x)\,dx = F_X\big(g^{-1}(y)\big).

For yy below JJ (i.e. y≤inf⁡Jy \le \inf J), Ay∩I=∅A_y \cap I = \emptyset so FY(y)=0F_Y(y) = 0; for yy above JJ, Ay⊇IA_y \supseteq I so FY(y)=1F_Y(y)=1. This confirms YY takes values (with probability one) in J‾\overline J and matches the claim that fYf_Y vanishes outside JJ.

Step 3 (differentiate). For yy in the interior of JJ, FY(y)=FX(g−1(y))F_Y(y) = F_X(g^{-1}(y)) is a composition of the differentiable function g−1g^{-1} with FXF_X. We use that FXF_X is differentiable at every point where fXf_X is continuous, with FX′=fXF_X' = f_X there — this is the Fundamental Theorem of Calculus applied to the definition FX(x)=∫−∞xfX(t) dtF_X(x) = \int_{-\infty}^x f_X(t)\,dt, valid at continuity points of fXf_X, 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,

fY(y)=FY′(y)=FX′(g−1(y))⋅(g−1)′(y)=fX(g−1(y))⋅(g−1)′(y).f_Y(y) = F_Y'(y) = F_X'\big(g^{-1}(y)\big)\cdot (g^{-1})'(y) = f_X\big(g^{-1}(y)\big)\cdot (g^{-1})'(y).

Since gg is strictly increasing, (g−1)′(y)=1/g′(g−1(y))>0(g^{-1})'(y) = 1/g'(g^{-1}(y)) > 0 (as g′>0g' > 0 everywhere on II for an increasing differentiable bijection — if g′(x0)<0g'(x_0)<0 at some point, gg would be locally decreasing near x0x_0, contradicting strict monotonicity globally combined with the intermediate value theorem applied to g′g', which cannot change sign without vanishing since g′≠0g'\neq0 throughout), so (g−1)′(y)=∣(g−1)′(y)∣(g^{-1})'(y) = |(g^{-1})'(y)|, giving exactly

fY(y)=fX(g−1(y)) ∣(g−1)′(y)∣.f_Y(y) = f_X(g^{-1}(y))\,\big|(g^{-1})'(y)\big|.

Step 4 (decreasing case, sign check). If gg is strictly decreasing, the same Step 2 argument with the decreasing case of the monotonic preimage lemma gives FY(y)=P(X≥g−1(y))=1−FX(g−1(y))F_Y(y) = P(X \ge g^{-1}(y)) = 1 - F_X(g^{-1}(y)) (using that XX is continuous so single points have probability zero, hence P(X≥a)=1−P(X<a)=1−FX(a)P(X\ge a) = 1-P(X<a) = 1-F_X(a)). Differentiating,

fY(y)=−fX(g−1(y))⋅(g−1)′(y).f_Y(y) = -f_X(g^{-1}(y))\cdot (g^{-1})'(y).

Here g′<0g' < 0 throughout II (by the same sign-constancy argument as above, applied to the decreasing case), so (g−1)′(y)=1/g′(g−1(y))<0(g^{-1})'(y) = 1/g'(g^{-1}(y)) < 0, hence −(g−1)′(y)=∣(g−1)′(y)∣>0-(g^{-1})'(y) = |(g^{-1})'(y)| > 0, and again

fY(y)=fX(g−1(y)) ∣(g−1)′(y)∣.f_Y(y) = f_X(g^{-1}(y))\,|(g^{-1})'(y)|.

Both monotonicity cases yield the identical stated formula, completing the proof. ■\blacksquare

∎
CorollaryPiecewise-monotonic change of variables

Let XX be continuous with density fXf_X supported on II, and let g:I→Rg: I \to \mathbb R be such that II decomposes into finitely (or countably) many disjoint open intervals I1,I2,…I_1, I_2, \dots (with a Lebesgue-null leftover set of "boundary" points) on each of which gg restricts to a strictly monotonic, differentiable bijection gk:Ik→Jkg_k: I_k \to J_k with nonvanishing derivative. Then Y=g(X)Y = g(X) has density

fY(y)=∑k: y∈JkfX(gk−1(y)) ∣(gk−1)′(y)∣.f_Y(y) = \sum_{k:\, y \in J_k} f_X\big(g_k^{-1}(y)\big)\, \big|(g_k^{-1})'(y)\big|.
Proof

The boundary set N=I∖⋃kIkN = I \setminus \bigcup_k I_k is Lebesgue-null by hypothesis, so P(X∈N)=∫NfX=0P(X \in N) = \int_N f_X = 0 and we may ignore it: P(X∈Ik for some k)=1P(X \in I_k \text{ for some } k) = 1. The events {X∈Ik}\{X \in I_k\} partition Ω\Omega up to a null set, so

FY(y)=P(g(X)≤y)=∑kP(X∈Ik, g(X)≤y)=∑kP(X∈Ik∩gk−1((−∞,y])),F_Y(y) = P(g(X) \le y) = \sum_k P(X \in I_k,\ g(X) \le y) = \sum_k P\big(X \in I_k \cap g_k^{-1}((-\infty,y])\big),

using countable additivity of PP over the disjoint events {X∈Ik,g(X)≤y}\{X\in I_k, g(X)\le y\} — this is a direct application of countable additivity of probability measures to a countable disjoint union, which is part of the axiomatic definition of PP, hence not circular. On IkI_k, gg agrees with the strictly monotonic bijection gkg_k, so by the Monotonic preimage lemma, Ik∩gk−1((−∞,y])I_k \cap g_k^{-1}((-\infty,y]) equals Ik∩(−∞,gk−1(y)]I_k \cap (-\infty, g_k^{-1}(y)] or Ik∩[gk−1(y),∞)I_k\cap[g_k^{-1}(y),\infty) according to whether gkg_k increases or decreases (and is empty if y∉Jky \notin J_k). Each summand is therefore ∫IkfX(x) 1[x on the correct side] dx\int_{I_k} f_X(x)\,\mathbb 1[x \text{ on the correct side}]\,dx, and differentiating the resulting sum termwise (justified because it is a finite, or locally finite, sum of differentiable functions of yy) applies the single-branch change-of-variables theorem to each term, yielding the stated sum. ■\blacksquare

∎

Worked examples

Example 1 (asymmetric linear-then-nonlinear transformation, using the CDF method to sanity-check the Jacobian method). Let X∼Exponential(λ)X \sim \mathrm{Exponential}(\lambda) with λ=2\lambda = 2, so fX(x)=2e−2xf_X(x) = 2e^{-2x} for x>0x>0 and FX(x)=1−e−2xF_X(x) = 1-e^{-2x} for x>0x > 0. Let

Y=g(X)=3−5X,Y = g(X) = 3 - 5X,

an asymmetric affine transformation (not just a rescaling): it shifts by 33, flips sign, and stretches by 55. Find fYf_Y. CDF method. Since X>0X>0 a.s., Y=3−5X<3Y = 3-5X < 3 a.s. For y<3y < 3,

FY(y)=P(3−5X≤y)=P(X≥3−y5)=1−FX(3−y5)=1−(1−e−2⋅3−y5)=e−2(3−y)5.F_Y(y) = P(3-5X \le y) = P\Big(X \ge \frac{3-y}{5}\Big) = 1 - F_X\Big(\frac{3-y}{5}\Big) = 1-\Big(1-e^{-2\cdot\frac{3-y}{5}}\Big) = e^{-\frac{2(3-y)}{5}}.

For y≥3y \ge 3, FY(y)=1F_Y(y) = 1 (in fact this formula extended continuously gives 11 at y=3y=3, consistent). Differentiating for y<3y<3:

fY(y)=ddye−2(3−y)5=25e−2(3−y)5,y<3,f_Y(y) = \frac{d}{dy} e^{-\frac{2(3-y)}{5}} = \frac{2}{5}e^{-\frac{2(3-y)}{5}}, \qquad y < 3,

and fY(y)=0f_Y(y)=0 for y≥3y \ge 3. Jacobian method, as a check. Here g(x)=3−5xg(x) = 3-5x is strictly decreasing on I=(0,∞)I=(0,\infty), with inverse g−1(y)=3−y5g^{-1}(y) = \frac{3-y}{5} and (g−1)′(y)=−15(g^{-1})'(y) = -\frac15, so ∣(g−1)′(y)∣=15|(g^{-1})'(y)| = \frac15. The range is J=g((0,∞))=(−∞,3)J = g((0,\infty)) = (-\infty,3). By the theorem,

fY(y)=fX(3−y5)⋅15=2 e−2⋅3−y5⋅15=25e−2(3−y)5,y<3,f_Y(y) = f_X\Big(\frac{3-y}{5}\Big)\cdot\frac15 = 2\,e^{-2\cdot\frac{3-y}{5}}\cdot\frac15 = \frac25 e^{-\frac{2(3-y)}{5}}, \qquad y<3,

matching the CDF-method answer exactly. As a numerical check, at y=−2y=-2: 3−y5=1\frac{3-y}{5} = 1, so fY(−2)=25e−2≈0.4×0.1353=0.05413f_Y(-2) = \frac25 e^{-2} \approx 0.4\times 0.1353 = 0.05413; total mass check ∫−∞3fY(y) dy=∫0∞fX(x) dx=1\int_{-\infty}^3 f_Y(y)\,dy = \int_0^\infty f_X(x)\,dx = 1 by substitution, as it must.

Example 2 (non-monotonic transformation, needing the piecewise-monotonic corollary). Let X∼N(1,4)X \sim N(1,4) (mean 11, variance 44, so σ=2\sigma=2), with density

fX(x)=122πexp⁡(−(x−1)28),x∈R.f_X(x) = \frac{1}{2\sqrt{2\pi}}\exp\left(-\frac{(x-1)^2}{8}\right), \qquad x \in \mathbb R.

Let Y=X2Y = X^2. Since XX is not centered at 00, this is a genuinely asymmetric instance of squaring — the two branches contribute unequally. Find fY(y)f_Y(y) for y>0y > 0. Here g(x)=x2g(x) = x^2 is not globally monotonic on R\mathbb R, but splits into two strictly monotonic branches: I1=(−∞,0)I_1 = (-\infty, 0) with g1(x)=x2g_1(x) = x^2 strictly decreasing, inverse g1−1(y)=−yg_1^{-1}(y) = -\sqrt y; and I2=(0,∞)I_2 = (0,\infty) with g2(x)=x2g_2(x)=x^2 strictly increasing, inverse g2−1(y)=yg_2^{-1}(y) = \sqrt y. Both map onto J=(0,∞)J = (0,\infty). In each case ∣(gk−1)′(y)∣=∣±12y∣=12y|(g_k^{-1})'(y)| = \left|\pm\frac{1}{2\sqrt y}\right| = \frac{1}{2\sqrt y}. By the Piecewise-monotonic change of variables corollary, for y>0y>0:

fY(y)=fX(−y)⋅12y+fX(y)⋅12y=12y[fX(y)+fX(−y)].f_Y(y) = f_X(-\sqrt y)\cdot\frac{1}{2\sqrt y} + f_X(\sqrt y)\cdot\frac{1}{2\sqrt y} = \frac{1}{2\sqrt y}\Big[f_X(\sqrt y) + f_X(-\sqrt y)\Big].

Plugging in fXf_X:

fY(y)=12y⋅122π[exp⁡(−(y−1)28)+exp⁡(−(−y−1)28)],y>0.f_Y(y) = \frac{1}{2\sqrt y}\cdot\frac{1}{2\sqrt{2\pi}}\left[\exp\left(-\frac{(\sqrt y - 1)^2}{8}\right) + \exp\left(-\frac{(-\sqrt y-1)^2}{8}\right)\right], \qquad y>0.

Note the two exponential terms are not equal (unlike the standard-normal case X∼N(0,1)X\sim N(0,1), where they'd coincide and give the familiar χ12\chi^2_1 density) — this asymmetry is exactly the point of choosing mean 1≠01\neq 0. As a numerical spot check at y=1y=1 (so y=1\sqrt y = 1): the two exponents are −(1−1)28=0-\frac{(1-1)^2}{8}=0 and −(−1−1)28=−48=−0.5-\frac{(-1-1)^2}{8} = -\frac{4}{8}=-0.5, giving

fY(1)=12⋅122π[e0+e−0.5]=142π[1+0.6065]≈1.606510.0265≈0.1603.f_Y(1) = \frac{1}{2}\cdot\frac{1}{2\sqrt{2\pi}}\big[e^{0} + e^{-0.5}\big] = \frac{1}{4\sqrt{2\pi}}\big[1+0.6065\big] \approx \frac{1.6065}{10.0265} \approx 0.1603.

One can confirm this is sensible: since fX(y)f_X(\sqrt y) dominates fX(−y)f_X(-\sqrt y) whenever y\sqrt y is close to the mean 11 (as here), the "positive branch" contributes the bulk of the density, illustrating exactly why the naive shortcut of doubling one branch (valid only when XX is symmetric about 00) would be wrong here.

CounterexampleWhy differentiability / nonvanishing derivative cannot be dropped from the change-of-variables theorem

Consider X∼Uniform(−1,1)X \sim \mathrm{Uniform}(-1,1), so fX(x)=12f_X(x) = \tfrac12 for x∈(−1,1)x\in(-1,1), and let

g(x)=x3.g(x) = x^3.

This gg is a strictly increasing, continuous bijection from (−1,1)(-1,1) onto (−1,1)(-1,1) — monotonic, so the hypotheses of the general monotonic-preimage lemma still apply and the CDF method still works perfectly. But g′(x)=3x2g'(x) = 3x^2 vanishes at x=0x=0, 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 g−1(y)=y1/3g^{-1}(y) = y^{1/3}, with derivative (g−1)′(y)=13y−2/3(g^{-1})'(y) = \frac13 y^{-2/3}, which blows up as y→0y \to 0 (it is undefined at y=0y=0 and unbounded near it), even though gg itself is perfectly well-behaved and Y=X3Y=X^3 certainly has a legitimate, bounded density. Applying the formula naively gives

fY(y)  ‘‘="  fX(y1/3)⋅13∣y∣−2/3=12⋅13∣y∣−2/3=16∣y∣−2/3,y∈(−1,1),f_Y(y) \;``="\; f_X(y^{1/3})\cdot \frac13 |y|^{-2/3} = \frac12\cdot\frac13|y|^{-2/3} = \frac{1}{6}|y|^{-2/3}, \qquad y\in(-1,1),

which integrates to 11 over (−1,1)(-1,1) (one can check ∫−1116∣y∣−2/3dy=13∫01y−2/3dy=13⋅3=1\int_{-1}^1 \frac16 |y|^{-2/3}dy = \frac13\int_0^1 y^{-2/3}dy = \frac13\cdot 3 = 1) and is in fact the correct answer here — because even though (g−1)′(g^{-1})' blows up at the single point y=0y=0, it remains integrable, and the derivation of FY=FX∘g−1F_Y = F_X\circ g^{-1} 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

g(x)=x−sin⁡x,g(x) = x - \sin x,

which satisfies g′(x)=1−cos⁡x≥0g'(x) = 1-\cos x \ge 0 with equality at isolated points x=2πkx = 2\pi k, and is still strictly increasing overall (since g′g' vanishes only at isolated points, not on an interval, gg remains injective) — this again survives, illustrating that isolated zeros of g′g' are a genuine edge case but not always fatal. The hypothesis truly bites when gg is not injective near a critical point. Take g(x)=x2g(x) = x^2 near x=0x=0 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 00, e.g. naively writing g−1(y)=yg^{-1}(y) = \sqrt y for X∼Uniform(−1,1)X\sim \mathrm{Uniform}(-1,1) without splitting into branches. Since gg maps both xx and −x-x to the same y=x2y=x^2, the single-branch formula

fY(y)  ‘‘="  fX(y) ∣(y)′∣=12⋅12y=14yf_Y(y) \;``="\; f_X(\sqrt y)\,\big|(\sqrt y)'\big| = \frac12\cdot\frac{1}{2\sqrt y} = \frac{1}{4\sqrt y}

integrates to ∫0114y dy=12≠1\int_0^1 \frac{1}{4\sqrt y}\,dy = \frac12 \neq 1: it loses half the mass, precisely the mass belonging to the branch x<0x<0 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 gg is genuinely two-to-one) produces a function that fails even to integrate to 11, 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 11, as verified in Example 2 above.

Scope, edge cases & common traps

SituationCorrect toolCommon error
gg strictly monotonic, differentiable, g′≠0g'\neq0Single-branch Jacobian formulaForgetting the absolute value on (g−1)′(y)(g^{-1})'(y), giving negative "density" for decreasing gg
gg piecewise monotonic (e.g. x2x^2, ∣x∣|x|, sin⁡x\sin x on [0,2π][0,2\pi])Sum over branches (corollary)Applying single-branch formula and silently losing mass from other branches
gg has isolated critical points but stays injectiveJacobian formula still applies away from critical points; density may blow up (integrably) thereConcluding the theorem "fails" whenever g′=0g'=0 anywhere, even at isolated non-flat points
gg not injective and not smooth (e.g. discontinuous, or constant on an interval)CDF method onlyTrying to force a Jacobian formula where no local inverse derivative exists
XX discreteDirect pushforward: P(Y=y)=∑x:g(x)=yP(X=x)P(Y=y) = \sum_{x: g(x)=y} P(X=x)Attempting to use a density-based Jacobian formula on a discrete variable
gg continuous but not differentiable at isolated points (e.g. g(x)=∣x∣g(x)=|x|)CDF method, or piecewise Jacobian avoiding the kinkDifferentiating FYF_Y 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
AN
Andrei Nikolaevich Kolmogorov
1903–1987 · Moscow School of Probability

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 PY(B)=P(X∈g−1(B))P_Y(B) = P(X\in g^{-1}(B)) rigorous rather than a computational trick, and it underlies every result in this article.

History
- 1900 — Henri Lebesgue's theory of measure and integration supplies the analytic backbone later used to define densities and pushforward measures rigorously.
- 1920s — Continuous distributions and their transformations are studied extensively in mathematical statistics (Fisher, Pearson), largely via formal density manipulations without full measure-theoretic justification.
- 1933 — Kolmogorov's axiomatization casts random variables as measurable functions, making P(X∈g−1(B))P(X\in g^{-1}(B)) a precise, general definition valid for arbitrary measurable gg.
- 1930s–1940s — The change-of-variables (Jacobian) formula for densities becomes standard machinery in mathematical statistics, used to derive the χ2\chi^2, tt, and FF sampling distributions from normal theory.
- 1950s onward — The probability integral transform and its inverse become foundational to Monte Carlo simulation as digital computers emerge, directly generalizing the ideas in this article.
Why do we need gg to be strictly monotonic for the Jacobian formula, rather than just differentiable?

Strict monotonicity guarantees gg has a well-defined, single-valued inverse g−1g^{-1} on its range, so that the preimage {x:g(x)≤y}\{x: g(x)\le y\} is a single ray (−∞,g−1(y)](-\infty, g^{-1}(y)] or [g−1(y),∞)[g^{-1}(y),\infty), as shown in the monotonic preimage lemma. Without monotonicity, g−1(y)g^{-1}(y) may not exist as a function (multiple xx can map to the same yy), and the preimage set can be a complicated union of intervals whose measure cannot be written as a single evaluation of FXF_X. 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 XX is discrete with pmf pXp_X and gg is any function, then Y=g(X)Y=g(X) is discrete with pmf

pY(y)=∑x: g(x)=ypX(x),p_Y(y) = \sum_{x:\,g(x)=y} p_X(x),

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 xx's collide under gg. The CDF method of this article specializes correctly to this case, since FY(y)=P(X∈g−1((−∞,y]))F_Y(y)=P(X\in g^{-1}((-\infty,y])) remains valid verbatim for discrete XX.

What is the probability integral transform, and how does it relate to this article?

If XX is a continuous random variable with strictly increasing, continuous CDF FXF_X, then U:=FX(X)U := F_X(X) is exactly Uniform(0,1)\mathrm{Uniform}(0,1)-distributed. This is a direct instance of the change-of-variables theorem with g=FXg = F_X itself (which is strictly increasing and differentiable with derivative fXf_X), since the resulting density works out to the constant 11 on (0,1)(0,1). Running this transformation in reverse — starting from U∼Uniform(0,1)U\sim\mathrm{Uniform}(0,1) and setting X=FX−1(U)X = F_X^{-1}(U) — 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 gg fail to be injective yet still yield a computable density for Y=g(X)Y=g(X)?

Yes, as long as gg is piecewise monotonic with finitely (or countably) many differentiable, invertible branches on which g′≠0g'\neq0, as in the piecewise-monotonic corollary. The density of YY at a point yy is then the sum, over every branch whose range contains yy, of that branch's contribution fX(gk−1(y))∣(gk−1)′(y)∣f_X(g_k^{-1}(y))|(g_k^{-1})'(y)|. This is exactly how one derives, for instance, the density of Y=X2Y=X^2 or Y=sin⁡XY=\sin X (on an interval covering more than one monotonic piece) from a known density fXf_X.

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 {g(X)≤y}={X∈g−1((−∞,y])}\{g(X)\le y\} = \{X\in g^{-1}((-\infty,y])\}, which holds for any measurable gg 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 g−1g^{-1} — which in turn demands local invertibility and a nonvanishing derivative of gg. When gg fails to be smooth or invertible, FYF_Y may still be perfectly computable via the CDF method (perhaps not differentiable everywhere, or requiring case analysis of g−1((−∞,y])g^{-1}((-\infty,y])), 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. Z=g(X,Y)Z=g(X,Y)?

The same two-method dichotomy generalizes verbatim to higher dimensions. The CDF method still computes P(Z≤z)P(Z\le z) as P((X,Y)∈g−1((−∞,z]))P((X,Y)\in g^{-1}((-\infty,z])), a region-of-the-plane calculation using the joint density. The Jacobian method generalizes to the multivariate change-of-variables formula: if (X,Y)↦(U,V)=g(X,Y)(X,Y)\mapsto (U,V)=g(X,Y) 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 FF-distribution and behind normalizing flows in modern generative modeling.

Before this