Why Piecewise Transformations Need Care
A transformation can use different formulas on different parts of the input range, and even a single formula can turn around and produce multiple inputs for the same output. Both features matter: the output distribution depends on every input value that maps to the output, while the output support depends on the image of each part of the input range. If the images do not meet, the transformed variable can have a gap in its support.
The central method is to divide the input support into intervals on which the transformation is one-to-one and monotone. Then find the inverse on each interval. The CDF method works directly from the definition of probability; the density method adds the contributions from all inverse branches. These methods are aligned with the SOA VEE Mathematical Statistics syllabus.
Start With the CDF and the Full Preimage
For any \(y\), the definition of the transformed CDF is \(F_Y(y)=P(Y\le y)=P(g(X)\le y)\). The event on the right is a set of input values. Depending on the shape of \(g\), it may be one interval, several intervals, or no interval at all. Listing only one inverse value when several exist is a common source of error.
On a branch where \(g\) is increasing, the inequality \(g(X)\le y\) becomes \(X\le g^{-1}(y)\), restricted to that branch. On a decreasing branch it becomes \(X\ge g^{-1}(y)\). The CDF is found by combining the probabilities of all such pieces. This method also handles output values in gaps: if no input maps below a value within a particular gap, the CDF stays constant there.
Worked Example: A Transformation With a Gap in Its Image
Let \(X\) be uniform on \((-2,2)\), so \(f_X(x)=1/4\) on that interval. Define \(g(x)=x^2\) for \(-2<x<0\), and \(g(x)=x+6\) for \(0\le x<2\). Find the support and CDF of \(Y=g(X)\), then calculate \(P(Y\le1)\).
Method: find each branch image, then use the CDF. The first input interval maps to \((0,4]\), whose support closure is \([0,4]\). The second maps to \([6,8)\), whose support closure is \([6,8]\). Thus the support is \([0,4]\cup[6,8]\); no input produces an output between 4 and 6.
For \(0\le y\le4\), the condition \(x^2\le y\) on the negative branch is \(x\ge-\sqrt y\). The qualifying inputs run from \(-\sqrt y\) to 0, a length of \(\sqrt y\). Therefore \(F_Y(y)=(1/4)\sqrt y\). At \(y=4\), this gives \(1/2\), the probability of the negative half of the input range.
For \(4<y<6\), no additional inputs qualify, so the CDF remains \(1/2\). For \(6\le y\le8\), the second branch qualifies when \(x+6\le y\), or \(x\le y-6\). The added input length is \(y-6\), giving an added probability of \((y-6)/4\). Thus \(F_Y(y)=1/2+(y-6)/4\) on this interval. The CDF is 0 below 0 and 1 at and above 8.
Finally, \(Y\le1\) occurs on the first branch when \(-1\le X<0\), an interval of length 1. Hence \(P(Y\le1)=1/4=0.2500\). The result agrees with \(F_Y(1)=\sqrt{1}/4\).
Density Contributions From Multiple Inverse Branches
If \(g\) is differentiable and monotone on a branch, a small output interval near \(y\) corresponds to a small input interval near its inverse value \(x=g^{-1}(y)\). The input interval has approximate width \(dy/|g'(x)|\). Its probability is approximately \(f_X(x)dy/|g'(x)|\), so that branch contributes \(f_X(x)/|g'(x)|\) to the output density.
The absolute value is essential: density contributions are nonnegative whether the branch increases or decreases. For a piecewise transformation, the sum is also essential. Each input branch mapping to \(y\) contributes its own probability, even if the branches are described by different formulas.
Worked Example: Three Inverse Branches Overlap
Let \(X\) be uniform on \((0,3)\), with density \(1/3\). Define \(g(x)=(x-1)^2\) for \(0<x<2\), and \(g(x)=x-2\) for \(2\le x<3\). Find the density of \(Y=g(X)\) for \(0<y<1\), and calculate \(P(Y\le1/4)\).
Method: split at the turning point and include every inverse. On the first input interval, \(g(x)=(x-1)^2\) decreases to 0 and then increases, so split it at \(x=1\). For \(0<y<1\), its two inverse values are \(x=1-\sqrt y\) and \(x=1+\sqrt y\). Each has \(|g'(x)|=|2(x-1)|=2\sqrt y\), so each contributes \((1/3)/(2\sqrt y)=1/(6\sqrt y)\).
The second formula, \(g(x)=x-2\), has inverse \(x=2+y\) for \(0<y<1\). It contributes \((1/3)/1=1/3\). All three inverses are in the input support, so \(f_Y(y)=1/(3\sqrt y)+1/3\) for \(0<y<1\).
To calculate the requested probability directly, the first branch satisfies \((x-1)^2\le1/4\) when \(1/2\le x\le3/2\), an interval of length 1. The second branch satisfies \(x-2\le1/4\) when \(2\le x\le9/4\), of length \(1/4\). The total qualifying input length is \(1+1/4=5/4\). Dividing by the input interval length 3 gives \(P(Y\le1/4)=5/12=0.4167\), to four decimal places.
As a check, integrating the density from 0 to \(1/4\) gives \((1/3)\sqrt y\big|_0^{1/4}+(1/3)y\big|_0^{1/4}=1/6+1/12=1/4\). This does not match \(5/12\), so the check reveals a missing factor in that antiderivative: the integral of \(1/(3\sqrt y)\) is \((2/3)\sqrt y\). The corrected integral is \(1/3+1/12=5/12\), matching the direct calculation.
Disconnected Support With a Nonuniform Input
The branch method does not require \(X\) to be uniform. With a nonuniform density, each inverse contribution is weighted by the input density at that inverse value. The same support analysis still applies: determine each branch’s image before deciding where the transformed density can be positive.
Worked Example: An Exponential Input and a Piecewise Map
Suppose \(X\) has an exponential distribution with rate 1, so \(f_X(x)=e^{-x}\) for \(x\ge0\). Define \(g(x)=x\) for \(0\le x<1\), and \(g(x)=3+(x-1)^2\) for \(x\ge1\). Find the support, the density on each support piece, and \(P(Y\le4)\).
Method: map the two input branches and transform each density. The first branch has image \([0,1)\), with support closure \([0,1]\). The second has image \([3,\infty)\). The transformed support is therefore \([0,1]\cup[3,\infty)\); the interval \((1,3)\) is a gap.
On \(0<y<1\), the inverse is \(x=y\), with derivative 1. Thus \(f_Y(y)=e^{-y}\). For \(y>3\), the inverse is \(x=1+\sqrt{y-3}\), with derivative \(1/(2\sqrt{y-3})\). The density there is \(f_Y(y)=e^{-(1+\sqrt{y-3})}/(2\sqrt{y-3})\).
The event \(Y\le4\) includes every input \(0\le X<1\). On the second branch it requires \(3+(X-1)^2\le4\), which, since \(X\ge1\), is equivalent to \(X\le2\). Hence \(Y\le4\) exactly when \(X\le2\), up to endpoints of probability zero. Therefore \(P(Y\le4)=1-e^{-2}=0.8647\), to four decimal places. This also agrees with the exponential CDF evaluated at 2.
Derivation and Practical Checks
The density formula follows by comparing probabilities over a short output interval. Consider one monotone branch with inverse \(x=g^{-1}(y)\), and take a small positive width \(h\). The input values that map into \((y,y+h)\) lie between \(g^{-1}(y)\) and \(g^{-1}(y+h)\), with the order reversed if the branch is decreasing. The probability is the integral of \(f_X\) over that interval. For small \(h\), its approximate value is \(f_X(x)|g^{-1}(y+h)-g^{-1}(y)|\).
Dividing by \(h\) and taking the limit gives \(f_X(x)|(g^{-1})'(y)|\). Differentiating \(g(g^{-1}(y))=y\) gives \((g^{-1})'(y)=1/g'(x)\). Thus one branch contributes \(f_X(x)/|g'(x)|\). If several disjoint input branches map to the same output interval, their probabilities add, so their density contributions add as well.
The argument assumes a continuous input distribution and differentiable, one-to-one branches with nonzero derivative in the region where the formula is used. A zero derivative at a turning point can make the density unbounded nearby; this does not by itself imply a point mass. If the input distribution has an atom at a point \(x_0\), its probability is instead carried to an atom at \(g(x_0)\), and the continuous-density formula alone does not account for it.
Split wherever the formula changes or a branch changes direction, such as at a turning point.
Find the image interval for each input branch. Their union identifies the transformed support and any gaps.
For each output region, list every input value in the support that maps to that output.
Use the full preimage for the CDF, or add \(f_X(x)/|g'(x)|\) over all inverse branches for the density.
Common Mistake: Forgetting an Inverse Branch
In the three-branch example, at \(y=1/4\) the inverse inputs are \(1/2\), \(3/2\), and \(9/4\). A tempting but incorrect calculation keeps only the two roots of the square branch and obtains \(P(Y\le1/4)=1/3\), since the corresponding input length is 1 out of a total length of 3. This omits the interval \([2,9/4]\) from the second branch.
The correction is to solve the inequality on every branch. The omitted interval has length \(1/4\), so the full probability is \((1+1/4)/3=5/12\). A separate trap is to assume the output support is one continuous interval just because the input support is continuous. The first and third worked examples show why each branch image must be checked before making that assumption.
Check Your Understanding
For each problem, identify all relevant input branches before calculating.
- \(X\) is uniform on \((-3,1)\). Let \(g(x)=x+3\) for \(x<0\) and \(g(x)=5+x\) for \(x\ge0\). State the transformed support and find \(P(Y\le2)\). (Answer: support \([0,3]\cup[5,6]\); \(P(Y\le2)=0.5000\).)
- \(X\) is uniform on \((0,2)\). Let \(g(x)=x^2\) for \(0<x<1\) and \(g(x)=2-x\) for \(1\le x<2\). Find \(P(Y\le1/4)\). (Answer: \(3/8=0.3750\).)
- \(X\) is exponential with rate 2. Let \(g(x)=x\) for \(0\le x<1\), and \(g(x)=3+(x-1)^2\) for \(x\ge1\). State the support and find \(P(Y\le4)\). (Answer: support \([0,1]\cup[3,\infty)\); \(1-e^{-4}=0.9817\).)
- \(X\) is uniform on \((0,3)\). Let \(g(x)=x^2\) for \(0<x<1\), \(g(x)=2-x\) for \(1\le x<2\), and \(g(x)=x-2\) for \(2\le x<3\). Find \(f_Y(y)\) for \(0<y<1\). (Answer: \(f_Y(y)=1/(6\sqrt y)+2/3\).)
- \(X\) is uniform on \((-1,2)\). Let \(g(x)=x^2\) for \(-1\le x<1\) and \(g(x)=x+3\) for \(1\le x\le2\). Find \(P(Y\le1/4\text{ or }Y\ge4.5)\). (Answer: \(0.5000\).)