# $Y \sim \mathrm{Uniform}(0,1)$, $[X|Y=y] \sim \mathrm{Uniform}(0,1/y).$ Find $f_X(x)$

This was a quiz question that I answered but don't understand something that is probably very important.

Question:

Let $Y \sim \mathrm{Uniform}(0,1)$ and $[X|Y=y] \sim \mathrm{Uniform}(0,1/y).$ Find $f_X(x)$.

Solution (Attempt):

We have $$f_X(x|y) = y$$ for $y \in (0,1)$ and $x \in (0,1/y)$.

Then,

$$f_X(x) = \int_{-\infty}^\infty f_X(x|y) \cdot f_Y(y) \mathrm{d}y = \int_0^1 y \mathrm{d}y = \frac{1}{2}.$$

From here I argued that we need $$\int_{-\infty}^\infty f_X(x) \mathrm{d}x = 1$$

so $X \sim \mathrm{Uniform}(0,2)$ will satisfy this condition.

However, my professor has noted that

$$f_X(x) = \frac{1}{2}$$

for $x \in [0,1]$ but I did not cover the case of $x > 1$ in which she then goes on to do the following:

$$f_X(x) = \int_{0}^{ 1/x } y \mathrm{d}y = \frac{1}{2x^2}$$ for $x > 1$.

Trying to understand this, it makes me think that the former case that I did, was just for the case of $y = 1$ and then the part that professor did was for $y \in (0,1).$ But that isn't making that much sense as it seems then the integral I computed would have just been $1$. I am guessing something is happening where $X$ is distributed on some interval $(0,1/y)$ which ends at $1/y$ which varies and could be a large number.

-
In short: indicator functions are part of the densities hence always write your densities with their indicator function part. – Did Dec 5 '12 at 8:43

You have the correct approach in your argument but need to be more careful with the limits of the integral. One way to better track the integral limits is to write the conditional distribution $f(X \mid Y)$ as

\begin{eqnarray} f_{X \mid Y}(x \mid y) &=& \left\{ \begin{array}{cc} y & 0 \leq x \leq \frac{1}{y} \\ 0 & x > \frac{1}{y} \end{array} \right. \\ &=& y \mathbf{1}_{0 \leq y \leq \frac{1}{x}} \end{eqnarray}

Now, writing out your expression for $f_X(x)$, we have

\begin{eqnarray} f_X(x) = \int_0^1 f_{X \mid Y}(x \mid y) f_Y(y) dy = \int_0^1 y\mathbf{1}_{0 \leq y \leq \frac{1}{x}} dy \end{eqnarray}

For a given value of $x$, the conditional pdf $f(X \mid Y)$ has non-zero value only if $0 \leq y \leq \frac{1}{x}$. If $x < 1$, this is trivially satisfied since $y$ is anyway upper bounded by 1. So your derivation is correct in this regime. If $x > 1$, the above integral will split into two as

\begin{eqnarray} \int_0^1 y\mathbf{1}_{0 \leq x \leq \frac{1}{y}} dy &=& \int_0^{\frac{1}{x}} y\mathbf{1}_{0 \leq y \leq \frac{1}{x}} dy + \int_{\frac{1}{x}}^1 y\mathbf{1}_{0 \leq y \leq \frac{1}{x}} dy \\ &=& \int_0^{\frac{1}{x}} y \cdot 1 \, dy + \int_{\frac{1}{x}}^{1} y \cdot 0 \, dy \\ &=& \frac{1}{2x^2} \end{eqnarray}

-
Beat me to it. Nice job. +1 – StuartHa Dec 5 '12 at 8:21
Thank you very much I appreciate it. Best – Frudrururu Dec 7 '12 at 3:17