# probability density function for a random variable

For a given probability density function $f(x)$, how do I find out the probability density function for say,

$Y = x^2$? $$f(x)=\begin{cases}cx&,0<x<2\\2c&,2<x<5\\0&,\text{otherwise}\end{cases}$$

• Are you familiar with change of variables for an integral? – Braindead Feb 6 '14 at 5:39

HINT 1: Note that $P(Y < 0) = 0$ (since $Y = X^2 \geq 0$) and for $y >0$, \begin{gather*} P(Y \leq y) = P(X^2 \leq y) = P(-\sqrt{y} \leq X \leq \sqrt{y}) = \dots \end{gather*}

HINT 2: For any $z \in \mathbb{R}$, $P(X \leq z) = \int_0^z f(x) dx$. Now evaluate the integral as a piecewise function, from $0$ to $2$ and then from $2$ to $5$, and plug back into HINT 1.

This particular method for solving the problem is decently intuitive, but it freely abuses some notation of calculus.

In some non-rigorous sense, if we say that random variable $X$ has probability distribution $f(x)$, what we mean is that $Pr(X = x) = f(x) dx$. If we want to define a new random variable $Y = g(X)$ (for your purposes, $g$ squares $X$), then we can write:

$$Pr(g^{-1}(Y) = x) = f(x)dx$$ $$Pr(Y = g(x)) = f(x) dx$$

Substitute $g^{-1}(g(x))$ for $x$:

$$Pr(Y = g(x)) = f(g^{-1}(g(x))) d(g^{-1}(g(x))$$

Let $a = g(x)$:

$$Pr(Y = a) = (f(g^{-1}(a))) (\frac{dg^{-1}(a)}{da}) da$$

Which means that the PDF for $Y$ (now written as a function of $y$) is the function $$f(g^{-1}(y)) (\frac{dg^{-1}(y)}{dy})$$

If $X$ was defined on $[a, b]$, then $Y$ is defined on $[g(a), g(b)]$. Note that this works only if $g$ is monotonically increasing on $[a, b]$ (why?)! Luckily, in your case - where $g$ is the squared function, and $X$ only takes positive values, this is true.

Let's call the probability density for the random variables $X$ and $Y$ as $f_X$ and $f_Y$, respectively.

$f_Y$ has the property that $Pr[a\le Y \le b] = \int_a^b f_Y(y) dy$.

You want to know what this $f_Y$ is using $f_X$.

Since you want $Y = X^2$, note that

$Pr[a\le Y \le b] = Pr[a\le X^2 \le b]$

Let's assume that $a$ and $b$ are both positive (Q: Why is it okay to do this?), so

$\displaystyle Pr[a\le X^2 \le b] = Pr[\sqrt{a} \le X \le \sqrt{b}] = \int_{\sqrt{a}}^{\sqrt{b}} f_X(x) dx$.

(Question: Why am I only taking the positive square root?)

But this isn't quite what you want. You want the integral in terms of $y$. And also, the bounds should be from $a$ to $b$, but this will be fixed once we perform a change of variables.

Use the fact that $y = x^2$. Then, $\sqrt{y} = x$, so

$$Pr[a\le Y \le b] = \int_{a}^{b} \dfrac{f_X(\sqrt{y})}{2\sqrt{y}} dy$$

So $f_Y(y) = \dfrac{f_X(\sqrt{y})}{2\sqrt{y}}$