How to find density of a given finction. I was solving the following problem : X is a continuous random variable with density $f_X(x) = 1 - |x|$ for $-1<x<1$ and $0$ elsewhere. I need to find the density of $Y= |X|$. Can anyone help me how to proceed this problem? I am quite new to statistics subject. Thanks for the help. 
 A: The transformation $X\mapsto \lvert X\rvert$ maps the support $(-1;0)\cup[0;1)$ onto $[0;1)$.   This procedure is called folding because it can be visualised as doing that : two halves of the interval are folded together.
Further, since there is no change in scale we need not worry about using Jacobian determinants and can leave that as a topic for later research.   Here the density components from the two semi-intervals of the preimage are simply combined additively to give the density of the image at any point.
$$\begin{align}f_{\lvert X\rvert}(y) &= f_X(-y)\cdot\mathbf 1_{y\in(0;1)}+f_X(y)\cdot\mathbf 1_{y\in[0;1)}\\ &\ddots   \end{align}$$
A: Maybe you should go along the track of cumulative distribution functions (CDF). I'll try to sketch the basic steps of the plan:
The density function $f_X$ (regarding to the lebesgue measure) of the random variable $X$ defines a probability distribution $P_X$ via $$P_X(A):=P(X^{-1}(A))=\int_A f_X(t)d\lambda(t)$$
for all measurable $A$. The CDF is defined as $F_X(a):=P_X((-\infty,a])$. Our goal is to calculate the probability distribution of a transformed variable $Y:=\phi(X)$ via the CDF. For the CDF of $Y$ we have: $$F_Y(a)=P_Y((-\infty,a])=P(Y^{-1}((-\infty,a]))=P((\phi\circ X)^{-1}((-\infty,a]))=P(X^{-1}(\phi^{-1}((-\infty,a]))) = \int_{\phi^{-1}((-\infty,a])} f_X(t)d\lambda(t).$$
So the chief work of the problem is to calculate the set $\phi^{-1}((-\infty,a])$ for all $a\in\mathbb{R}$ and integrate $f_X$ over it. Then you can try to "cautiously differentiate" the function $F_Y(a)$ to get a density function $f_Y$ of $Y$. "cautiously" because $F_Y$ is just continuous in general and then there is just some sort of weak derivation.
In our case, we have $\phi(x):=|x|$ and $f_X(x)=(1-|x|)\cdot\chi_{[-1,1]}(x)$. It is easy to check that $$\phi^{-1}((-\infty,a]) = |\cdot|^{-1}((-\infty,a]) = |\cdot|^{-1}((0,a]) = [-a,a]$$ and thus we obtain 
$$F_Y(a) = \int_{\phi^{-1}((-\infty,a])} f_X(t)d\lambda(t) = \int_{[-a,a]} (1-|x|)\cdot\chi_{[-1,1]}(x)d\lambda(t) = \int_{[-a,a]\cap[-1,1]} 1-|x|d\lambda(t) = 2\int_{[0,a]\cap[0,1]} 1-x\ d\lambda(t) = 2\int_{[0,a]\cap[0,1]} 1-x\ d\lambda(t) =\begin{cases}0&, a<0\\2a-a^2 &, a\in[0,1]\\ 1&, a>1 \end{cases}.$$
Now you can get a density function $f_Y$ of $Y$ by differentiating outside the nullset $\{0,1\}$ (and choosing arbitrary values in $0$ resp. $1$ - doesnt matter because its a nullset):
$$f_Y(a) = \begin{cases}0&, a<=0\\2-2a &, a\in(0,1)\\ 1&, a\geq1 \end{cases}.$$
