Is this "the" method to get the pdf of a squared triangular distribution?

$$f_X(x) = \begin{cases} 1-x, &{0 \leq x \leq 1}\\ 1+x, &{-1 \leq x < 0}\\ 0 , &\text{otherwise}\\ \end{cases}$$

The pdf or cdf transformation $Y=X^2$ can be derived either by drawing triangles or possibly by doing a change of random variables with the corresponding Jacobian:

$$\rm dy=2x \, dx\implies \rm dx=\frac{\rm dy}{2 \sqrt y}$$

Since $x=\pm \sqrt y,$ considering $x=-\sqrt y$ the inverse transformation will map to $[-1,0]$ with pdf $1-x,$ and

$$f_Y(y^-) \rm dy=\frac{1+ \left(-\sqrt y \right)}{2 \sqrt y}\rm dy=\frac 1 2 \left(\frac{1}{\sqrt y} -1\right)\rm dy.$$

If, on the other hand, $x=+\sqrt y,$ the inverse transformation will map to $[0,1]$ and

$$f_Y(y^+)\rm dy= \frac{1- \sqrt y }{2 \sqrt y}\rm dy=\frac 1 2 \left(\frac{1}{\sqrt y} -1\right)\rm dy.$$

It makes sense to add these probabilities to extract the pdf:

$$f_Y(y)= \frac1{\sqrt y}-1$$

with support from $[0,1].$


Solution 1:

An alternate, faster approach, using cumulative distribution functions.

$$F_{|X|}(y)=P(|X|<y)=\int_{-y}^y f_X(x)\,dx$$ when $y=[0,1].$ This is $$2\int_0^y (1-x)\,dx =2y-y^2.$$

So $$\begin{align}F_{X^2}(y)&=P(X^2<y)\\&=P(|X|<\sqrt y)\\&=F_{|X|}(\sqrt y)\\&=2\sqrt y-y \end{align} $$ for $y\in [0,1].$

Then $f_{X^2}(y)$ is the derivative of $F_{X^2},$ $$\frac1{\sqrt y}-1.$$