Let X be a random variable and g:R→R a function; the goal is to find the probabilistic description of the random variable Y=g(X).
For discreteX the problem is already solved:
pY(yℓ)=xk:g(xk)=yℓ∑pX(xk).
For general random variables the problem is slightly more complicated.
Problem. For Y=g(X), given FX(x) or fX(x) and the function g(x), find FY(y) and/or fY(y).
Since the general problem is considered, X can be discrete, absolutely continuous or mixed. Depending on the "interaction" between fX(x) and g(x) anything can happen: discrete X→ discrete Y, absolutely continuous X→ absolutely continuous Y, absolutely continuous X→ discrete Y, absolutely continuous X→ mixed Y.
In the formulas below 1(x) denotes the unit step function (zero for x<0, one for x≥0, as the use 1(k−1) for the support k≥1 of a geometric variable shows) and χA the indicator function of a set A.
General strategy: start from the distribution function
Find the DF of Y first:
FY(y)=P(Y≤y)=P(g(X)≤y)=P(X∈g−1((−∞,y])).
The density, when it exists, is obtained by differentiating: fY(y)=dydFY(y). The formula looks very abstract; the only way to understand how it works is practice, so several examples follow.
Example 1: affine function Y=aX+b
Let X∼fX(x). Then
FY(y)=P(aX+b≤y)=⎩⎨⎧P(X≤ay−b)P(X≥ay−b)a>0a<0
(the figure shows the line g(x)=ax+b for a>0 and a<0: the set {x:g(x)≤y} is the half line to the left of x=ay−b if a>0, to the right if a<0). Hence
FY(y)=⎩⎨⎧FX(ay−b)1−FX(ay−b)a>0a<0
and taking the derivative
fY(y)=∣a∣1fX(ay−b)(∗)
The part of the computation that takes the inverse images g−1((−∞,y]) and writes FY in terms of FX does not depend on the actual form of FX or fX.
Special case 1: Gaussian.Y=aX+b, X∼N(μ,σ2)⇒Y∼N(aμ+b,a2σ2). This is derived by substituting the N(μ,σ2) density in (∗).
Special case 2: uniform.Y=aX+b, X∼U([c,d]) gives
Y∼{U([ac+b,ad+b])U([ad+b,ac+b])a>0a<0
Proof (case a>0): fX(x)=d−c1χ[c,d](x), so by (∗)
Special case 2: X∼Exp(λ). Then Y∼Exp(λ). No computation is necessary: on the support of the density of X the function g is the identity, Y=g(X)=X for all x≥0.
Special case 3: X uniform. Without computations one can convince oneself that:
This is a very important density in probability and statistics, called χ2(1) (chi-square with 1 degree of freedom): if X∼N(0,1) then X2∼χ2(1).
Example 4: other common functions
Simple signal transformations very common in electronics (graphs on the page): half wave rectifier x1(x), full wave rectifier ∣x∣, limiter (a linear part saturating at both ends), rectifier and limiter, full wave rectifier and limiter, etc.
Interactions between g(x) and fX(x)
Typical behaviours of Y=g(X) depend on the interaction between the properties of g and of fX.
g is constant over an interval. If g(x)=y∗ for x∈[a,b] and P(X∈[a,b])>0 then P(Y=y∗)=P(X∈[a,b])>0, and Ycannot be an absolutely continuous random variable.
g has a jump at x∗. The figure shows a jump from yℓ to yh at x∗; then
P(Y∈(yℓ,yh))=P(X=x∗)={0>0X absolutely continuousX discrete and x∗∈X.
Exercise (informal solutions)
g(x)={11−xx≤0x>0
X∼N(0,1). The probability mass in (−∞,0), that is 21, is all mapped in Y=1. The mass in (0,∞) is mapped linearly into (−∞,1). So
fY(y)=2π1e−21(y−1)21(1−y)+21δ(y−1),
or as a mixture fY(y)=21[2π2e−21(y−1)21(1−y)]+21δ(y−1) (a Gaussian-shaped part on y<1 plus an atom of weight 21 at y=1).
X∼Exp(λ). The probability mass in (−∞,0) is 0, therefore P(Y=1)=0; the mass in (0,∞) is mapped linearly into (−∞,1):
fY(y)=λe−λ(1−y)1(1−y).
Alternative method: piecewise invertible g
If Y=g(X) where g is piecewise invertible, i.e. a function with a finite number of points x where g′(x)=0 (it is monotonic, increasing or decreasing, between consecutive such points, hence invertible on each of those intervals), the density fY(y) can be found with a different approach.
Lemma. If g∈C1(R) (differentiable with continuous derivative) and g has at most a finite number of points x where g′(x)=0, then g is piecewise invertible.
Proof. Let x1<x2<⋯<xN be the points where g′(xi)=0. The sign of g′(x) is constant over the intervals (−∞,x1),(x1,x2),…,(xN−1,xN),(xN,+∞), therefore g is monotonic over each interval, thus invertible. □
Theorem. Let g∈C1(R) with a finite number of zeros of g′(x), and let X be absolutely continuous with density fX(x). Then Y=g(X) is absolutely continuous with density
fY(y)=a∈g−1(y)∑∣g′(a)∣fX(a)
Proof (case g′(a)>0). Take a=g−1(y) and a small increment h of y. The tangent at a has slope tanβ=h′h=g′(a), where h′ is the corresponding increment of x, so h′=g′(a)1h. Then
Case g′(a)<0. Now tanβ=g′(a)=h′h<0 so the interval of x corresponding to (y,y+h) lies to the left of a (figure) and has positive length h′=∣g′(a)∣1h (a length must be positive). Reasoning as before, whatever the sign of g′(a)=0,
fY(y)=∣g′(a)∣fX(a),a=g−1(y).
In generalg−1(y) contains several points a1,a2,a3,… (figure: a horizontal strip (y,y+h) cuts the graph above several intervals of x); the contributions of all the small x-intervals add up:
fY(y)=ai∈g−1(y)∑∣g′(ai)∣1fX(ai).□
Example: g(x)=x2.g′(x)=2x=0 only at x=0. For y>0, g−1(y)={−y,y}, with g′(−y)=−2y and g′(y)=2y. Hence
X∼Exp(λ), a>0, b=0: Y∼Exp(λ/a); for b=0 or a<0, Y is not exponential (wrong support).
RectifierY=X1(X): FY(y)=FX(y)1(y). For X∼N(0,1): fY=fX(y)1(y)+21δ(y) (mixed, P(Y=0)=21). Exp is unchanged. U([−1,3])→41δ(y)+43U([0,3]).
SquareY=X2: FY=(FX(y)−FX(−y))1(y), fY(y)=2y1[fX(y)+fX(−y)]1(y). X∼N(0,1)⇒X2∼χ2(1) with density 2πy1e−y/21(y).
Interactions:g constant on an interval of positive probability ⇒ atom, Y not absolutely continuous. A jump of g at x∗ gives P(Y∈gap)=P(X=x∗): 0 for absolutely continuous X.
Density formula.g∈C1, finitely many zeros of g′ (piecewise invertible), X absolutely continuous:
fY(y)=a∈g−1(y)∑∣g′(a)∣fX(a).
Idea: fY(y)h=P(X∈(a,a+h′))=fX(a)h′ with h′=h/∣g′(a)∣.
Typical mistakes. Forgetting the absolute value ∣a∣ or ∣g′(a)∣; forgetting an atom when g is constant on a set of positive probability; using the density formula when g′ vanishes on an interval; forgetting that 1(y) (support) must be kept.