Why Composition Needs Care
A random variable is sometimes transformed in stages: first \(Y=g(X)\), then \(Z=h(Y)\). It is tempting to calculate each density separately and stop there, but the final answer depends on correctly connecting the intermediate supports, inverse maps, and derivative factors. The central bookkeeping fact is that the inverse of a composition reverses the order of the maps: \( (h\circ g)^{-1}=g^{-1}\circ h^{-1}\).
For densities, each stage contributes a one-dimensional Jacobian factor: the absolute derivative of the inverse transformation. For a sequence of stages, those factors multiply. The chain rule ensures that their product is exactly the factor obtained by treating the entire transformation as one map. We make the conditions and this agreement precise below.
Two Successive Transformations
Suppose \(X\) has density \(f\) on an open interval \(I\), with \(P(X\in I)=1\). Let \(g:I\to J\) and \(h:J\to K\) be bijections between open intervals. Assume \(g\) and \(h\) are continuously differentiable and their derivatives are nowhere zero on their respective domains. These assumptions ensure that each inverse is continuously differentiable and that the one-dimensional density change-of-variables formula applies at each stage.
The intermediate variable has density \(f_Y(y)=f(g^{-1}(y))|(g^{-1})'(y)|\) on \(J\). Applying the same formula to \(Z=h(Y)\) gives \(f_Z(z)=f_Y(h^{-1}(z))|(h^{-1})'(z)|\). Substituting the expression for \(f_Y\) yields the theorem's sequential formula. Its equality to the direct formula follows from the chain rule:
Taking absolute values turns the derivative product into the product of the two absolute derivative factors. The inverse order matters: to recover the original value from \(z\), first undo \(h\), then undo \(g\). This is why the inverse is \(g^{-1}\circ h^{-1}\), not \(h^{-1}\circ g^{-1}\).
Proof of the Density Agreement
Here is a direct verification that the sequential calculation gives a density for the final variable and agrees with the composite calculation. Let \(A\) be any Borel subset of \(K\). Since \(Z=h(g(X))\), \(P(Z\in A)=P(X\in T^{-1}(A))\). Applying the density formula for \(X\) and then the one-dimensional change of variables \(x=T^{-1}(z)\) gives
The change of variables is valid because \(T=h\circ g\) is a continuously differentiable bijection with nowhere-zero derivative: \(T'(x)=h'(g(x))g'(x)\), and both factors are nonzero. Thus the last integrand is a density of \(Z\). On the other hand, applying the one-dimensional formula first to \(g\) and then to \(h\) gives the sequential expression in the theorem. The chain rule for \(T^{-1}=g^{-1}\circ h^{-1}\) shows that expression equals the direct density at every \(z\in K\). Both calculations therefore describe the same law. \(\square\)
More Than Two Stages
The same reasoning extends to any finite sequence. Let \(I_0,I_1,\ldots,I_m\) be open intervals and, for \(j=1,\ldots,m\), let \(g_j:I_{j-1}\to I_j\) be a continuously differentiable bijection with nowhere-zero derivative. If \(X_0\) has density \(f_0\) on \(I_0\), define \(X_j=g_j(X_{j-1})\). The inverse of the full map \(T=g_m\circ\cdots\circ g_1\) reverses every stage: \(T^{-1}=g_1^{-1}\circ\cdots\circ g_m^{-1}\).
To see why, at stage \(j\) the current value is \(X_j\), so the density update multiplies by \(\left|(g_j^{-1})'(X_j)\right|\). When the final value is \(z=X_m\), the value at stage \(j\) is recovered by undoing all later maps: \(X_j=g_{j+1}^{-1}\circ\cdots\circ g_m^{-1}(z)\). This gives the displayed product. Equivalently, repeatedly applying the chain rule to \(T^{-1}\) gives exactly those same factors. This is a finite repetition of the two-stage result, not a new transformation rule.
Worked Example: A Uniform Variable, a Logarithm, and a Square
Let \(X\sim\operatorname{Uniform}(0,1)\). First set \(Y=-\log X\), then \(Z=Y^2\). Find the density of \(Z\) sequentially and by composing the transformations.
The first map sends \(x\in(0,1)\) to \(y\in(0,\infty)\). Its inverse is \(x=e^{-y}\), with absolute derivative \(e^{-y}\). Since \(f_X(x)=1\) on \((0,1)\),
The second map \(z=y^2\) is a bijection from \((0,\infty)\) to \((0,\infty)\). Its inverse is \(y=\sqrt{z}\), whose derivative is \(1/(2\sqrt{z})\). Therefore the sequential calculation gives
For the direct calculation, \(T(x)=(-\log x)^2\), and solving \(z=(-\log x)^2\) for \(x\in(0,1)\) gives \(T^{-1}(z)=e^{-\sqrt{z}}\). Thus
The expressions agree. As a normalization check, substitute \(u=\sqrt{z}\), so \(dz=2u\,du\): \(\int_0^\infty e^{-\sqrt{z}}/(2\sqrt{z})\,dz=\int_0^\infty e^{-u}\,du=1\).
Worked Example: Reciprocal Followed by Logarithm
Let \(X\sim\operatorname{Exponential}(\lambda)\), where \(\lambda>0\), with density \(f_X(x)=\lambda e^{-\lambda x}\) for \(x>0\). Set \(Y=1/X\), then \(Z=\log Y\). Find the density of \(Z\) both ways.
For the reciprocal map \(x\mapsto 1/x\), the inverse is also \(x=1/y\), and the absolute inverse derivative is \(1/y^2\). Hence
The logarithm maps \(y>0\) to \(z\in\mathbb{R}\). Its inverse is \(y=e^z\), with derivative \(e^z\). The sequential result is
Directly, \(T(x)=\log(1/x)=-\log x\), so \(T^{-1}(z)=e^{-z}\) and \(\left|(T^{-1})'(z)\right|=e^{-z}\). Thus \(f_Z(z)=\lambda e^{-\lambda e^{-z}}e^{-z}\), the same expression. It integrates to one: with \(t=\lambda e^{-z}\), \(dt=-t\,dz\) and \(\lambda e^{-z}=t\), giving \(\int_{-\infty}^{\infty}\lambda e^{-z}e^{-\lambda e^{-z}}\,dz=\int_0^\infty e^{-t}\,dt=1\).
Worked Example: Affine Transformation Followed by a Logarithm
Let \(X\sim\operatorname{Uniform}(0,2)\), and define \(Y=2X+1\) and \(Z=\log Y\). Find the support and density of \(Z\) by both methods.
The first map sends \((0,2)\) to \((1,5)\). Its inverse is \(x=(y-1)/2\), with absolute derivative \(1/2\), so \(f_Y(y)=(1/2)(1/2)=1/4\) for \(1<y<5\). For \(z=\log y\), the inverse is \(y=e^z\) and its derivative is \(e^z\). The transformed support is \(0<z<\log 5\), and the sequential density is
For the direct map \(T(x)=\log(2x+1)\), the inverse is \(T^{-1}(z)=(e^z-1)/2\), with derivative \(e^z/2\). Therefore \(f_Z(z)=(1/2)(e^z/2)=e^z/4\) on the same support. The density normalizes: \(\int_0^{\log 5}e^z/4\,dz=(5-1)/4=1\).
Common Mistakes and Why the Rule Matters
The composition rule is useful whenever a distribution is easier to obtain in stages, or when a complicated final expression can be checked by an independent direct calculation. The intermediate variable is not merely a convenience: its support tells you where the next transformation is defined, and its inverse derivative contributes a factor that must be retained.
- Multiplying forward derivatives as if they were density factors. The density formula uses absolute derivatives of the inverse maps. Forward derivatives can be used only in the equivalent form \(f_X(x)/|T'(x)|\), evaluated at \(x=T^{-1}(z)\).
- Reversing the inverse order incorrectly. To invert \(h(g(x))\), first undo \(h\), then \(g\). Hence \((h\circ g)^{-1}=g^{-1}\circ h^{-1}\).
- Forgetting the intermediate support. A second map must be applied to values in the range of the first map. Keep track of the image interval at every stage before writing the final density.
- Dropping absolute values. A decreasing map has a negative inverse derivative, but a density must use its absolute value. The reciprocal-and-logarithm example has a decreasing first stage; its density factor is positive.
Check Your Understanding
Use inverse maps and supports explicitly when answering.
- If \(T=h\circ g\), in what order must \(g\) and \(h\) be undone to obtain \(T^{-1}\)?
- Suppose \(X\sim\operatorname{Uniform}(0,1)\), \(Y=2X+1\), and \(Z=\log Y\). What is the support of \(Z\), and which inverse derivative factors appear in the sequential density?
- For \(Z=h(g(X))\), explain why the chain rule makes the sequential and direct density calculations agree.
- Why must a density transformation use the absolute value of an inverse derivative when a stage is decreasing?
- For a three-stage composition, describe how to recover the intermediate value immediately before the final stage from the final value.