Question
Suppose that $X \sim\mathcal{Uniform}(1,2)$ and $Y\mid X = x \sim\mathcal{Uniform}(0, x)$ for $0$ to $2$ and otherwise zero.
a) Find the joint PDF of $X$ and $Y$ .
b) Find the marginal density function for $Y$.
Solution
$f(x) = \begin{cases}1 &\text{for}& 1 ≤ x ≤ 2\\ 0 &&\text{otherwise}\end{cases}$
$f(y\mid x) = \begin{cases}1/x &\text{for}& 0 ≤ y ≤ x\\0&&\text{otherwise}\end{cases}$
And the solution state that :
$\begin{align}f(y) :&=\begin{cases} 0&\text{for}& y\lt 0\\ \int_1^2 1/x\,\mathrm dx&& 0\leq y\leq 1 \\ \int_y^2 1/x\,\mathrm d x && 1 \leq y \lt 2\\ 0&&2\leq y\end{cases} \\ &= \begin{cases} 0&\text{for}& y\lt 0\\ \ln 2 && 0\leq y\lt 1\\ \ln 2-\ln y && 1 \leq y \lt 2\\ 0&& 2\leq y \end{cases}\end{align}$
I have asked my professor thrice but still couldn't understand the splitting of these integration and the term come up.
Can anyone help ?
Notice that the margin for $X$ is supported over $1\leq X\leq 2$, and while the conditional of $Y$ given $X$ is supported over $0\leq Y\leq X$. This allows $Y$ to be less or greater than $1$.
$$\{(x,y): 1\leq x\leq 2~\wedge~0\leq y\leq x\}=\{(x,y):0\leq y\lt 1\leq x\leq 2~\vee~1\leq y\leq x\leq 2\} $$
So your joint pdf is $$f_{X,Y}(x,y)=\begin{cases} 1/x && 0\leq y\lt 1\leq x\leq 2\\ 1/x && \qquad 1\leq y\leq x\leq 2\\0&&\text{otherwise}\end{cases}$$
So when integrating with respect $x$ relative to $y$, the lower bound is $\max\{y,1\}$. When $y\lt 1$ this is $1$, but when $y\geq 1$ this is $y$.
Thus you partition the marginal function at this juncture (also at 0 and 2) giving rise to the piecewise function:
$$f_Y(y) = \begin{cases}0 && \qquad y\lt 0\\\int_1^2 1/x\,\mathrm d x&&0\leq y\lt 1\\\int_y^2 1/x\,\mathrm d x && 1\leq y\lt 2\\ 0&& 2\leq y \end{cases}$$