General PDF of square of uniform random variable for arbitrary a, b.

density functionprobabilityprobability distributionsrandom variablesuniform distribution

I want to know a general way to express the PDF of $Y = X^2$ for $X\sim U(a,b)$ arbitrary $a$ and $b$ such that $a < b$ and $a,b \in \mathbb{R}$.

EDIT: Thank you Graham Kemp for the answer that I approved below. I am going to retrace my understanding of his steps here so that others searching for this topic do not get confused.

When considering the mapping $X \to X^2$ for random variable $X$, the scalar to scalar change of variables in the probability density function is sufficient for our use, but could be generalized to random vectors. Let $g:\mathbb{R}\to\mathbb{R}$ monotonic and Y = g(x), then the PDF of $Y$ is given by
$$f_Y(y) =
f_{X}(g^{-1}(y))\left|\frac{d}{dy}g^{-1}(y)\right|
$$

For our case, since $g(x) = x^2$, we know that $g^{-1}(x) = \pm\sqrt{x}$ so we can plug this in to obtain
$$
f_Y(y) = f_X\left(\sqrt{y}\right)\left|\frac{d}{dy}\left(\sqrt{y}\right)\right| + f_X\left(-\sqrt{y}\right)\left|\frac{d}{dy}\left(-\sqrt{y}\right)\right|
$$

Computing this yields the function
$$
f_Y(y) = \frac{\mathbb{1}\{\sqrt{y}\in(a, b)\}}{2\sqrt{y}(b-a)}\mathbb{1}\{y\in[0, \infty)\} + \frac{\mathbb{1}\{\sqrt{y}\in(-b, -a)\}}{2\sqrt{y}(b-a)}\mathbb{1}\{y\in[0, \infty)\}
$$

The reason we can express the function in this way is based on the following observations:

  1. $\sqrt{y} \in \mathbb{R}$ only if $y \geq 0$
  2. If $a,b < 0$ or $a,b > 0$ then $\sqrt{y} \geq 0$ can only satisfy one of the numerators.
  3. Otherwise, Graham Kemp says, we experience folding of the support of Y, where the support of $X$ overlaps with itself after being squared. In this case, $\sqrt{y}$ can satisfy both indicators.

We can now rewrite this PDF in a more succinct form:
$$
f_Y(y) = \frac{\mathbb{1}\left\{\sqrt{y}\in(a, b)\right\} + \mathbb{1}\left\{\sqrt{y}\in(-b, -a)\right\}}{2\sqrt{y}(b-a)}\mathbb{1}\left\{y\in[0, \infty)\right\}\\
$$

Best Answer

Because $X\mapsto X^2$ has two semi-inverses, the Jacobian transformation is:$$\begin{align}f_{X^2}(y)&=\left|\frac{d(\surd y)}{dy}\right|f_{X}(\surd y)+\left|\frac{d(-\surd y)}{dy}\right|f_{X}(-\surd y)\\&=\frac{\mathbf 1_{a\leq\surd y\leq b}+\mathbf 1_{-b\leq\surd y\leq-a}}{2(b-a)\surd y}\cdot\mathbf 1_{0<y}\end{align}$$So for example, should we take $X\sim\mathcal U(-1,2)$ then $$\begin{align}f_{\small X^2}(y) & =(6\surd y)^{-1}(\mathbf 1_{0<\surd y\leq 2}+\mathbf 1_{0<\surd y\leq 1})\\&=\dfrac{\mathbf 1_{0<y\leq 1}}{3\surd y}+\frac{\mathbf 1_{1<y\leq 4}}{6\surd y}\end{align}$$


Welcome to the concept of folding.

When $a<0<b$ the support for the pdf of $X$ is $[a,0]\cup(0,b]$.

Now under the transformation $X\mapsto X^2$, these two disjoint parts of the support will map to overlapping domains: as $[a,0]\mapsto[0,a^2]$ and $(0,b]\mapsto(0,b^2]$ . So they fold together: $$[a,0]\cup(0,b]\mapsto[0,\min(a^2,b^2)]\cup(\min(a^2,b^2),\max(a^2,b^2)]$$

So where $a<0<b$ we obtain:

$$\begin{align}f_{X^2}(y)&=\frac{\mathbf 1_{0\leq y\leq\min(a^2,b^2)}}{(b-a)\surd y}+\frac{\mathbf 1_{\min(a^2,b^2)\leq y\leq\max(a^2,b^2)}}{2(b-a)\surd y}\end{align}$$


In the two cases where $0$ is not included inside the support $[a,b]$, there will be no such folding, and the support maps bijectively, $[a,b]\mapsto [\min(a^2,b^2),\max(a^2,b^2)]$, and we simply obtain:

$$\begin{align}f_{X^2}(y)&=\frac{\mathbf 1_{\min(a^2,b^2)\leq y\leq\max(a^2,b^2)}}{2(b-a)\surd y}\end{align}$$