The joint pdf of $(X,Y)$ is given by,
$f_{X,Y}(x,y)=1$ if $0<x<2,0<y<1,2y\leq x$
Find the pdf of $U=X-Y$.
My attempt:
To solve the above, I consider the transformation $(X,Y)\rightarrow (U,Y)$.
$0<x<2,0<y<1\implies -1<u<2$
Again $2y\leq x \implies x-y\geq y \implies u\geq y>0$
So,$max(0,-1)<u<2 \implies 0<u<2$
Now, $x=u+y$
$0<x<2 \implies 0<u+y<2 \implies -u<y<2-u$
Again, $2y\leq x \implies 2y\leq u+y \implies y\leq u$
So, $max(0,-u)<y<min(2-u,u,1)$
$\implies 0<y<min(2-u,u,1)$ as $u>0$
$\implies 0<y<u$ when $u\in(0,1)$ and $0<y<2-u$ when $u\in(1,2)$
Jacobian of transformation is:
$J=J(\frac{x,y}{u,y})=\frac{\delta x}{\delta u}=1$
So, joint pdf of $(U,Y)$ is:
$f_{U,Y}(u,y)=f_{X,Y}(u+y,y)|J|$
$=1$, $0<u<2$ and $0<y<u$ if $u\in(0,1), 0<y<2-u$ if $u\in(1,2)$
So, marginal pdf of $U$ is:
$f_{U}(u)=\int_0^udy=u$ if $0<u<1$
$f_{U}(u)=\int_0^{2-u}dy=2-u$ if $1<u<2$
But I am not sure whether this is correct or I have messed up with the ranges. I have not found any illustration on distribution of function of two 'dependent' random variables when I searched. So I want to confirm this is the right approach. Any suggestion will be accepted. Thanks in advance.
let $Z = X-Y$ (potential)support of r.v is $(0,2)$. let $z \in (0,2)$
$$p_{Z}(z) =P(X-Y =z) = \int_{y=0}^{y=1}p(X-Y=z , Y=y) dy$$
$$ \hspace{4.0cm}= \int_{y=0}^{y=1} p(X = z+y , Y=y) dy$$
here if we use the fact that $0< X=z+y < 2 \implies -z < y < 2-z$ and using the fact that $0<y<1$ hence $0 < y < \min\{2-z,1 \} .$ and
we have to again use the fact that $2.y \leq x$ (here $x=z+y$ look at joint prob inside integral) $2y \leq z+y $ from which we have that $y \leq z$ and now we update our inequality on right size $0 < y < \min\{2-z,1,z\}$
$$ \hspace{6.0cm} = \int_{y=0}^{y= \min\{2-z,1,z\}} p(X= z+y , Y=y) . dy $$ $$ \hspace{4.0cm}= \min\{2-z,1,z\} $$
and we are done.
sometimes it is best you try to compute in brute-force way
Edit: Added justification about support of z
$x-y\geq x- x/2 = x/2 \geq 0$