# p.d.f of function of random variable

Suppose $X$ is a continuous random variable with p.d.f: $$f_X(x) = \begin{cases}1 & x \in [0, \frac{1}{2}) \\ 1 & x \in [1, \frac{3}{2}) \\ 0 & \text{otherwise} \end{cases}$$

What is the p.d.f of $Y = {(X - 1)}^2$?

Let's plot $g(X) = {(X - 1)}^2$ over the interval $0 \leq x \leq \frac{3}{2}$:

$g(X)$ is one-to-one over the interval $0 \leq x < \frac{1}{2}$ and is not one-to-one over $\frac{1}{2} \leq x \leq \frac{3}{2}$

So, consider $0 \leq y < \frac{1}{4}\quad$ ($\frac{1}{2} \leq x < \frac{3}{2}$):

$$\begin{eqnarray*} F_Y(y)&=&P(Y \leq y)\\ &=&P({(X - 1)}^2 \leq y)\\ &=&P(\sqrt{{(X - 1)}^2} \leq \sqrt{y})\\ &=&P(1 - \sqrt{y} \leq X \leq 1 + \sqrt{y})\\ &=&F_X(1 + \sqrt{y}) - F_X(1 - \sqrt{y})\\ f_Y(y)&=&F'_Y(y)\\ &=&F'_X(1 + \sqrt{y}) - F'_X(1 - \sqrt{y})\\ &=&f_X(1 + \sqrt{y})\cdot(1 + \sqrt{y})' - f_X(1 - \sqrt{y})\cdot(1 - \sqrt{y})'\\ &=&1\cdot\frac{1}{2}y^{-\frac{1}{2}} - 0\cdot(1 - \sqrt{y})'\\ &=&\frac{1}{2}y^{-\frac{1}{2}} \end{eqnarray*}$$

Note that $f_X(1 - \sqrt{y}) = 0$ because $f_X(x) = 0$ over $\frac{1}{2} \leq x < 1$

Now, consider $\frac{1}{4} \leq y < 1\quad$ ($0 \leq x < \frac{1}{2}$):

$$\begin{eqnarray*} F_Y(y)&=&P(Y \leq y)\\ &=&P((X - 1)^2 \leq y)\\ &=&P(\sqrt{(X - 1)^2} \leq \sqrt{y})\\ &=&P(- (X - 1) \leq \sqrt{y})\\ &=&P(X \geq 1 - \sqrt{y})\\ &=&1 - P(X \leq 1 - \sqrt{y})\\ &=&1 - F_X(1 - \sqrt{y})\\ f_Y(y)&=&F'_Y(y)\\ &=&- F'_X(1 - \sqrt{y})\\ &=&- f_X(1 - \sqrt{y})\cdot(1 - \sqrt{y})'\\ &=&- 1\cdot(- \frac{1}{2}y^{-\frac{1}{2}})\\ &=&\frac{1}{2}y^{-\frac{1}{2}} \end{eqnarray*}$$

Note that $\sqrt{(X - 1)^2} = - (X - 1)$ because $g$ is a decreasing function of $X$ over $0 \leq x < \frac{1}{2}$

So,

$$f_Y(y) = \begin{cases}\frac{1}{2}y^{-\frac{1}{2}} & y \in [0, \frac{1}{4}) \\ \frac{1}{2}y^{-\frac{1}{2}} & y \in [\frac{1}{4}, 1) \\ 0 & \text{otherwise} \end{cases}$$

Is this correct?

I did check and $\int_0^1 f_Y(y)\,\mathrm{d}y = 1$, but I am interested in the reasoning too.

• A short-cut is to note that |X-1| is uniformly distributed on [0,1], after which the standard procedure applies. – Did Oct 30 '13 at 15:28
• @Did: Your short-cut looks promising, but unfortunately I do not understand. Could you elaborate? I understand that $|X - 1|$ is uniformly distributed on $[0, 1]$, but do not know how to continue (e.g., $\sqrt{Y} = |X - 1|$, but how do I get $f_Y(y)$?). I am not seeing the relationship between $f_Y(y)$ and the fact that $|X - 1|$ is uniformly distributed on $[0, 1]$. – David Robert Jones Oct 31 '13 at 12:05
• If $Y=U^2$ with $U$ uniform on $(0,1)$ then $P(Y\leqslant y)=P(U\leqslant\sqrt{y})=\sqrt{y}$ for every $y$ in $(0,1)$, hence the density of $Y$. – Did Oct 31 '13 at 13:01

Actually, the function is one-to-one on the relevant domain. And the image (and hence the range of $Y$) is $(1/4,1] \cup [0,1/4]=[0,1]$

Hence, you can simply apply the formula $$f_Y(y)= \frac{f_X(x)}{|g'(x)|}=\frac{1}{2 |x-1|}$$

But $|x-1|= \sqrt{y}$

Hence $$f_Y(y) = \frac{1}{2 \sqrt{y}} , \hspace{1cm} y\in (0,1]$$

Your procedure is right, of course.

• Could you explain what you mean by "the function is one-to-one on the relevant domain"? What function? – David Robert Jones Oct 30 '13 at 17:51
• @DavidRobertJones : The transformation function $g(x)= (x-1)^2$ restricted to the relevant domain (support of $f_X(x)$) is one-to-one. – leonbloy Oct 30 '13 at 18:26

For a starter, the pdf of $X$ you posted is not a valid pdf. $\int_{-\infty}^{\infty} f_X(x) dx = \frac{3}{2}$. This also results in an incorret plot of $g(X)$. Which pdf do you mean?

• $\int_{-\infty}^\infty f_X(x)dx = \int_0^{\frac12}dx+\int_1^{\frac32}dx=1$ – Carlos Eugenio Thompson Pinzón Oct 30 '13 at 14:23