How does a function acting on a random variable change the probability density function of that random variable?

Given a random variable $X$ with probability density function $P(X)$, and given a transformation function $f(x)$, how does one determine the new resultant probability density function: $P(f(X))$?

For example:

Given random variable $X$ which is evenly distributed over the range $[0,2\pi ]$ such that $P(X) = \dfrac{1}{(2\pi)}$, what would be the probability density function of random variable $Y$ where $Y = \sin(X)$?

This blog post, explains how to get the pdf for $\sin(X)$, but I'd like to know if there is a way to solve this problem in the general case for a transformation of $f(X)$.


Solution 1:

As usual, see also here, one can fix a bounded measurable function $\varphi$ and consider $$ (*)=\mathrm E(\varphi(Y))=\mathrm E(\varphi(\sin X)). $$ By definition of the distribution of $X$, $$ (*)=\int_0^{2\pi}\varphi(\sin x)\frac{\mathrm dx}{2\pi}=\int_{-\pi/2}^{\pi/2}\varphi(\sin x)\frac{\mathrm dx}\pi. $$ The change of variable $y=\sin x$ yields $-1\leqslant y\leqslant1$ and $\mathrm dy=\cos x\mathrm dx=\sqrt{1-y^2}\mathrm dx$, hence $$ (*)=\int_{-1}^{1}\varphi(y)\frac{\mathrm dy}{\pi\sqrt{1-y^2}}. $$ This relation holds for every bounded measurable function $\varphi$ hence the distribution of $Y$ is the so-called arcsine distribution, with density $$ f_Y(y)=\frac{[|y|\lt1]}{\pi\sqrt{1-y^2}}. $$