Derive the CDF and PDF for W=X-Y

1.4k Views Asked by At

I have a problem where I do not know how to find the CDF and the PDF.

Problem:

I have the joint density for two random variables $X$ and $Y$:

$$ p(x,y) = \left\{ \begin{array}{ll} 1 & \quad \textrm{if}{\ } 0 < x < 2,{\ } y < x,{\ } y<2-x \\ 0 & \quad \textrm{otherwise} \end{array} \right. $$

I have found the marginal densities:

$$ f(x) = \left\{ \begin{array}{ll} 1 & \quad \textrm{if}{\ } 0 < x \leq 1\\ 2-x & \quad \textrm{if}{\ } 1 < x <2\\ 0 & \quad \textrm{otherwise} \end{array} \right. $$

$$ g(y) = \left\{ \begin{array}{ll} 2-2y & \quad \textrm{if}{\ } 0 < y < 1\\ 0 & \quad \textrm{otherwise} \end{array} \right. $$

Since the joint PDF is not a product of the marginal PDF's I conclude that the variables are dependent.

It is easy to find the marginal distributions:

$$ F(x) = \left\{ \begin{array}{ll} \frac{1}{2}x^2 & \quad \textrm{if}{\ } 0 < x \leq 1\\ 2x-\frac{1}{2}x^2-1 & \quad \textrm{if}{\ } 1 < x <2\\ 0 & \quad \textrm{if}{\ }x\leq0\\ 1 & \quad \textrm{if}{\ }x\geq2\\ \end{array} \right. $$ And: $$ G(y) = \left\{ \begin{array}{ll} 2y-y^2 & \quad \textrm{if}{\ } 0 < y < 1\\ 0 & \quad \textrm{if}{\ }y\leq0\\ 1 & \quad \textrm{if}{\ }y\geq1\\ \end{array} \right. $$

But I get stuck when I am asked to consider the variable $W=X-Y$ and find it's distribution and the PDF. My idea is:

$$H(w)=P(W\leq{}w)=P(X-Y\leq{}w)=\int_{0}^{2}P(X-Y\leq{}w|X=x)f(x)dx$$

But am not sure how to procede...

2

There are 2 best solutions below

2
On BEST ANSWER

$$H(w)=\int_{\mathbb{R^2}}{1_{x-y\leq w}p(x,y)dxdy}$$

Try to draw the surface, it is very intuitive. The surface where $p$ equals $1$ is the triangle with edges $(0,0),(2,0)$ and $(1,1)$

If $w\geq 2$, $H(w)=1$, as we only consider the surface of the above triangle,which is $1$

If $w\leq 0$ $H(w)=0$ as the intersection between the triangle and $\{y>x-w\}$ is empty.

Otherwise, we subtract the surface of the triangle with edges $(w,0),(2,0)$ and $(1+\frac{w}{2},1-\frac{w}{2})$ to the first triangle, which is $\frac{(2-w)^2}{4}$, therefore $$H(w)=1-\frac{(2-w)^2}{4}$$

1
On

Comment: Here is a simulation in R statistical software, based on 100,000 simulated realizatons of $(X, Y).$ Results are consistent with your marginals (approximated by tan histograms) and @Canardidi's CDF of $W$ for $0 < w < 2.$ The PDF on this support is $f_W(w) = 1 - w/2,$ as suggested by the blue histogram.

m = 10^5;  x = runif(m, 0, 2);  y = runif(m)
support = (y < x & y < 2 - x)
X = x[support];  Y = y[support];  W = X-Y

enter image description here

The probability $P(W \le 1)$ corresponds to the area of the histogram to the left of the vertical red line, and to the proportion of points above and to the left of the slanted red line in the scatterplot.