[Math] Probability : find $P(|X-y|<1/2)$ for a uniform distribution of $x,y$

probabilityuniform distribution

The question :
Two guys pick a random point between $[0,2]$ (uniform distribution) . find the probability that the distance between the points is < $0.5$
$$X – \text{first point} $$
$$Y – \text{second point}$$
so because they are random $$f(x,y)=f(x)*f(y)=0.25$$

So I wrote $$P(|X-Y|<0.5) = P(-0.5<x-y<0.5)= P(x-y<0.5)-p(x-y<-0.5)
=P(x<y+0.5)-p(x<y-0.5)$$

using the integrals

$$\int_0^2 \int_0^{y+0.5} 0.25 dxdy-\int_0^2 \int_0^{y-0.5}0.25 dxdy $$

I get $0.5$ and the answer is $7/16$ according to my professor.

What am I'm doing wrong ? I can draw the graph and see the limits but I think it's faster like that.

Thanks

Best Answer

Well your domain of integration is wrong. For example, $y+0.5$ goes beyond $2$.

enter image description here

It is always advisable to sketch a diagram.

A quick way to solve this question is simply calculate the corresponding area multiplied by the density.

$$\frac14 \left( 4 - 2 \times \frac12 \left( \frac32 \right)^2 \right) =1-\frac{9}{16}=\frac7{16}$$

Edit: \begin{align} &\int_0^2 \int_0^{y+0.5} f(x,y) \,dx \, dy - \int_0^2 \int_0^{y-0.5}f(x,y) \,dx \, dy \\ &=\int_0^2 \int_0^{y+0.5} \frac14 \mathbb{1}_{0 \leq x \leq 2, 0 \leq y \leq 2 } \,dx \, dy - \int_0^2 \int_0^{y-0.5}\frac14 \mathbb{1}_{0 \leq x \leq 2, 0 \leq y \leq 2 } \,dx \, dy \\ \\&=\int_0^2 \int_0^{\min(2,y+0.5)} \frac14\,dx \, dy-\int_{\frac12}^2 \int_0^{y-0.5} \frac14 \,dx\,dy \end{align}

Related Question