Density of transformed random variable

Suppose we are given the distribution of a continuous random variable \(X\). Let \(Y=\phi(X)\), where \(\phi\) is an invertible (one-to-one) function. Let \(\psi=\phi^{-1}\) so that \(X=\psi(Y)\). Furthermore,suppose \(\psi\) is differentiable. Then the p.d.f. of \(Y\) is \[ \begin{gather} g(y)=f(\psi(y))|\frac{dx}{dy}|\\ \text{where }x=\psi(y) \end{gather} \] From the equation, we can easily observe that \(|\frac{dx}{dy}|\) is the dispersion of \(Y\) when random variable \(X\) is transformed to random variable \(Y\). Thus one cannot simply replace \(X\) with \(\psi(y)\) to derive the density of \(Y\) without considering the difference of dispersion between \(X\) and \(Y\).

Proof:

Let \(G(y)\) represents the c.d.f. of \(Y\). first suppose \(\phi\) is a strictly increasing function. Then \(\psi=\phi^{-1}\) is also a strictly increasing function and \(d\psi(y)/dy>0\). Therefore \[ \begin{gather}\\ G(y)=P[Y\leq y]=P[\phi(X)\leq y]\\ =P(X\leq \phi^{-1}(y))=F(\psi(y)) \end{gather} \] Differentiating \(G(y)\) by using the chain rule, it follows that \[ \begin{gather} g(y)=\frac{dG(y)}{dy}=\frac{dF(\psi(y))}{dy}\\ =f(\psi(y))\frac{d\psi(y)}{dy}=f(\psi(y))\frac{dx}{dy} \end{gather} \] Next suppose \(\phi\) is a strictly decreasing function. Then \(\psi=\phi^{-1}\) is also a strictly decreasing function and \(d\psi(y)/dy<0\). Therefore \[ G(y)=P[Y\leq y] = P[\phi(X)\leq y]=P[X\geq\phi^{-1}(y)]=1-F(\psi(y)) \] Differentiating \(G(y)\) by using the chain rule, it follows that \[ \begin{gather} g(y)=\frac{dG(y)}{dy} = -\frac{dF(\psi(y))}{dy}\\ =-f(\psi(y))\frac{d\psi(y)}{dy}\\ =f(\psi(y))|\frac{dx}{dy}| \end{gather} \]

Example

Suppose \(Y=lnX\), where \(X\sim Beta(a,b)\).

  • Then we have p.d.f. of \(X\)

\[ \begin{gather} f_X(x)=\frac{x^{a-1}(1-x)^{b-1}}{B(a,b)}\\ \text{where }B(a,b)=\frac{\Gamma(a)\Gamma(b)}{\Gamma(a+b)}\\ x\in[0,1] \end{gather} \]

\[ \begin{gather} Y=\phi(X)=lnX\\ Y\in(-\infty,0]\\ X=\psi(Y)=e^Y\\ X\in[0,1] \end{gather} \]

  • Then we have p.d.f. of \(Y\)

\[ \begin{gather} g_Y(y)=f_X(\psi(y))|\frac{dx}{dy}|\\ =\frac{e^{y(a-1)}(1-e^y)^{b-1}}{B(a,b)}e^y\ (\frac{dx}{dy}=\frac{de^y}{dy}=e^y)\\ =\frac{e^{ay}(1-e^y)^{b-1}}{B(a,b)} \end{gather} \]

  • Next we derive the m.g.f. (moment generating function) of \(Y\)

\[ \begin{gather} M_Y(t)=E[e^{tY}]\\ =\int_{-\infty}^0e^{ty}g_Y(y)dy\\ =\int_{-\infty}^0\frac{e^{ay}(1-e^y)^{b-1}}{B(a,b)}e^{ty}dy\\ =\frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}\int_{-\infty}^0(e^y)^{a+t}(1-e^y)^{b-1}dy\\ =\frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}\int_0^1x^{a+t}(1-x)^{b-1}dlnx\ (e^y=e^{lnx}=x)\\ =\frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}\int_0^1x^{a+t}(1-x)^{b-1}\frac{1}{x}dx\\(\frac{dy}{dx}=\frac{dlnx}{dx}=\frac{1}{x}\Rightarrow dlnx=\frac{1}{x}dx)\\ =\frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}\int_0^1x^{a+t-1}(1-x)^{b-1}dx\\ =\frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}B(a+t,b)\int_0^1\frac{x^{a+t-1}(1-x)^{b-1}}{B(a+t,b)}dx\\ =\frac{\Gamma(a+b)}{\Gamma(a)\Gamma(b)}B(a+t,b)\\ (\int_0^1\frac{x^{a+t-1}(1-x)^{b-1}}{B(a+t,b)}dx\text{ is the integration of distribution }Beta(a+t,b)\text{ which is 1})\\ =\frac{\Gamma(a+b)\Gamma(a+t)\Gamma(b)}{\Gamma(a)\Gamma(b)\Gamma(a+b+t)}\\ =\frac{\Gamma(a+b)\Gamma(a+t)}{\Gamma(a+b+t)\Gamma(a)} \end{gather} \]