Transformations of probability density functions

1   Integration method

Let $X$ be a random variable with its probability density function $f_X(x)$ and define a transformation of this variable $y=g(x)$. Note its inverse transformation $x=g^{-1}(y)$. Since $f_X(x)$ is a probability density function, it has to satisfy:

  • $f_X(x)$ must be single-valued for all $x$,
  • $f_X(x)\geq 0$ for all $x$, and
  • $\int_{-\infty}^\infty f_X(x)\,dx=1$.

Now, the probability density function of $Y$, $f_Y(y)$, should also satisfy the same requirements above. That is, $y$ should be monotonically increasing or decreasing over the range of $x$. Otherwise, $f_Y(y)$ wouldn’t be single-valued for all $y$. In other words, $\frac{dy}{dx}\geq 0$ or $\frac{dy}{dx}\leq 0$ over the entire range of $x$ and it should not change its sign.

The probability of $a\leq X\leq b$ is \begin{equation} P(a\leq X < b)=\int_a^b f_X(x)dx. \end{equation}

For monotonically increasing $y$ over the range of $x$, the probability of $g(a)\leq Y\leq g(b)$ is \begin{equation} P\left(g(a)\leq Y < g(b)\right)=\int_{g(a)}^{g(b)}f_X\left(g^{-1}(y)\right)\frac{dx}{dy}dy \end{equation} and the probability density function of $Y$ can be obtained as \begin{equation} \begin{split} f_Y(y)&=f_X\left(g^{-1}(y)\right)\frac{dx}{dy}\\ &=f_X(x)\frac{dx}{dy}. \end{split} \label{eq:positive} \end{equation}

For monotonically decreasing $y$ over the range of $x$, \begin{equation} \begin{split} P\left(g(b)\leq Y < g(a)\right)&=\int_{g(b)}^{g(a)}f_X\left(g^{-1}(y)\right)\frac{dx}{dy}dy\\ &=-\int_{g(a)}^{g(b)}f_X\left(g^{-1}(y)\right)\frac{dx}{dy}dy \end{split} \end{equation} and \begin{equation} \begin{split} f_Y(y)&=-f_X\left(g^{-1}(y)\right)\frac{dx}{dy}\\ &=-f_X(x)\frac{dx}{dy}. \end{split} \label{eq:negative} \end{equation} Note $\frac{dx}{dy}\leq 0$.

Combining Eqs. \eqref{eq:positive} and \eqref{eq:negative} yields \begin{equation} f_Y(y)=f_X(x)\left|\frac{dx}{dy}\right|. \end{equation}

2   Derivation method

For monotonically increasing $y$ over the range of $x$, the cumulative density function of $Y$ is \begin{equation} \begin{split} F_Y(y)&=P(Y\leq y)\\ &=P(g(X)\leq y)\\ &=P\left(X\leq g^{-1}(y)\right)\\ &=F_X\left(g^{-1}(y)\right) \end{split} \end{equation} and the probability density function of $Y$ is \begin{equation} \begin{split} f_Y(y)&=\frac{d}{dy}F_Y(y)\\ &=\frac{d}{dy}F_X\left(g^{-1}(y)\right)\\ &=f_X\left(g^{-1}(y)\right)\frac{d}{dy}g^{-1}(y)\\ &=f_X(x)\frac{dx}{dy}. \end{split} \label{eq:positive2} \end{equation}

For monotonically decreasing $y$ over the range of $x$, \begin{equation} \begin{split} F_Y(y)&=P(Y\leq y)\\ &=P(g(X)\leq y)\\ &=P\left(X > g^{-1}(y)\right)\\ &=1-P\left(X\leq g^{-1}(y)\right)\\ &=1-F_X\left(g^{-1}(y)\right) \end{split} \end{equation} and \begin{equation} \begin{split} f_Y(y)&=\frac{d}{dy}F_Y(y)\\ &=\frac{d}{dy}\left[1-F_X\left(g^{-1}(y)\right)\right]\\ &=-f_X\left(g^{-1}(y)\right)\frac{d}{dy}g^{-1}(y)\\ &=-f_X(x)\frac{dx}{dy}. \end{split} \label{eq:negative2} \end{equation}

Combining Eqs. \eqref{eq:positive2} and \eqref{eq:negative2} yields \begin{equation} f_Y(y)=f_X(x)\left|\frac{dx}{dy}\right|. \end{equation}