If $X$ has a known density, what is the density of $Y = X^{2}$, or $Y = e^{X}$? The reliable route goes through the CDF: find $F_Y$ by solving an inequality, then differentiate with the chain rule.
Key idea
The CDF method: write $F_Y(y) = P(g(X) \le y)$ as a statement about $X$, compute it with $F_X$, then $f_Y = F_Y'$. For increasing (or decreasing) $g$ this gives $$f_Y(y) = f_X\left(g^{-1}(y)\right)\left\lvert \frac{d}{dy}g^{-1}(y) \right\rvert.$$
Why it works
For increasing $g$: $g(X) \le y$ exactly when $X \le g^{-1}(y)$, so $F_Y(y) = F_X(g^{-1}(y))$, and the chain rule gives $$f_Y(y) = f_X(g^{-1}(y)) \cdot \frac{d}{dy}g^{-1}(y)$$ For decreasing $g$ the inequality flips, $F_Y = 1 - F_X(g^{-1}(y))$, and the derivative brings a minus sign that the absolute value absorbs. The derivative factor has a picture: a thin strip of width $dx$ near $x$ carries probability $f_X(x)\,dx$, and $g$ stretches it to width $\lvert g'(x) \rvert\,dx$. The same probability over a wider strip means a lower density.
Worked examples
Worked example: Squaring a uniform
$X$ is uniform on $[0, 1]$ and $Y = X^{2}$. Find $f_Y$.
- For $0 < y < 1$: $$F_Y(y) = P(X^{2} \le y) = P(X \le \sqrt{y}) = \sqrt{y}$$
- $f_Y(y) = \frac{d}{dy}\sqrt{y} = \frac{1}{2\sqrt{y}}$ on $(0, 1)$.
- Check: $\int_{0}^{1} \frac{1}{2\sqrt{y}}\,dy = 1$.
Answer: $f_Y(y) = \frac{1}{2\sqrt{y}}$ for $0 < y < 1$.
Worked example: A logarithm
$X$ is uniform on $(0, 1)$ and $Y = -\ln X$. Find $f_Y$.
- $-\ln X \le y$ means $X \ge e^{-y}$, so $F_Y(y) = 1 - e^{-y}$ for $y > 0$.
- $f_Y(y) = e^{-y}$: exponential with rate 1. (This is how computers turn uniform random numbers into exponential ones.)
Answer: $f_Y(y) = e^{-y}$ for $y > 0$.
Worked example: A linear change
$f_X(x) = 2x$ on $[0, 1]$ and $Y = 2X + 3$. Find $f_Y$.
- $Y$ runs over $[3, 5]$, and $X = \frac{Y - 3}{2}$.
- $$f_Y(y) = f_X\left(\frac{y - 3}{2}\right) \cdot \frac{1}{2} = 2 \cdot \frac{y - 3}{2} \cdot \frac{1}{2} = \frac{y - 3}{2}$$ on $[3, 5]$.
- Check: $\int_{3}^{5} \frac{y - 3}{2}\,dy = 1$.
Answer: $f_Y(y) = \frac{y - 3}{2}$ on $[3, 5]$.
When $g$ is not one-to-one, add over every $x$ that maps to $y$. If $X$ is uniform on $[-1, 1]$ and $Y = X^{2}$, both $\sqrt{y}$ and $-\sqrt{y}$ map to $y$, each contributing $\frac{1/2}{2\sqrt{y}}$, so $f_Y(y) = \frac{1}{2\sqrt{y}}$ on $(0, 1)$. The CDF method handles this automatically: $F_Y(y) = P(-\sqrt{y} \le X \le \sqrt{y})$.
Common mistake
Substituting into the density, $f_Y(y) = f_X(g^{-1}(y))$, and dropping the derivative factor. For $Y = 2X + 3$ above, that would give $y - 3$ on $[3, 5]$, which has area 2. Check: every density you produce must have total area 1.