# 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)$.

-

## 1 Answer

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}}.$$

-
Hi Didier! What I don't understand in this derivation (and in the one before) is why you need the detour over the expectation? Can't you simply make of change of variables of the density as you do anyway? –  fabee Mar 9 '12 at 9:00
You can. But some people feel the derivation is more transparent and less error-prone when using what you call a detour, which I call a systematic approach. The advantages of said approach are especially striking, though, when one computes the density of a function of several random variables. –  Did Mar 9 '12 at 9:05
Thanks for the answer, but I still don't get it. I didn't mean any offense by detour, but I just don't get why it is necessary. What is more systematic about it than simply computing the determinant of the Jacobian (the absolute value of it) after making sure that your transformation is invertible? In short, assuming you have a density and an invertible transformation, I don't see why the expectation is necessary. –  fabee Mar 9 '12 at 12:10
You said it yourself: the transformation might not be invertible (the one in this question is not) and the resulting random variable might not have a density. Hence one can use the functional approach in a wider context. But, once again, the specific question here may be solved by other means. –  Did Mar 9 '12 at 15:38
Ok, then I think I got it. Thanks. –  fabee Mar 9 '12 at 16:29