# Joint Probability $\lvert X-Y \rvert$ of $2$ Uniformly Distributed Random Variables

Disclaimer: I know that there are multiple questions on this site about this exact same question, but none of them were helpful for my specific situation.

Here's a question I found in a probability textbook:

A man and a woman agree to meet at a certain location at about 12.30pm. If the man arrives at a time uniformly distributed between 12.15pm and 12.45pm, and if the woman independently arrives at a time uniformly distributed between 12.00pm and 1.00pm, find the probability that the first to arrive waits no longer than 5 minutes.

I'm not too sure how to obtain the answer (which is apparently $$\frac{1}{6}$$) to this question.

My attempt:

According to WolframAlpha, the integral evaluates to

Which differs from the answer provided, $$\frac{1}{6}$$.

Does anyone know where I went wrong?

• That would (probably, may be there are other errors that I don't see) if you would have $\int_a^b c\,dx = 0$ when $a > b$. But as it's negative - for example, in the first integral situations like "woman arrives in interval from $-30$ to $-20$" bring negative contribution, instead of zero. Commented Jun 9, 2022 at 20:26
• As a separate note, I think it's better to calculate integrals in such exercises manually - it often gives better understanding on what's happening - you would have a chance to catch that function under integral takes negative values - and also prepares you to situations when wolfram doesn't work. Commented Jun 9, 2022 at 20:27
• Duly noted! ^_^ Commented Jun 10, 2022 at 9:21

When solving such problems, it is often helpful to make a sketch of the support and the region in which the desired event occurs.

Here, the horizontal axis represents outcomes of $$X$$, corresponding to the random number of minutes of the man's arrival before or after 12:30, and the vertical axis represents outcomes of $$Y$$, corresponding to the random number of minutes of the woman's arrival before or after 12:30. The blue shaded region represents those outcomes satisfying the condition that they meet within five minutes of each other's arrival.

Because the joint density of their arrival times is joint uniform, it follows that the desired probability is simply the area of the blue region divided by the area of the support. Since the blue region is a parallelogram with base $$10$$ and height $$30$$, its area is $$300$$; the area of the support is $$(30)(60) = 1800$$, so the desired probability is $$1/6$$ as claimed.

However, the figure also gives insight as to how best to compute the probability analytically: your computation integrated with respect to $$x$$, then $$y$$; this amounts to partitioning the parallelogram into horizontal strips, which is why you have three cases. But the easier approach is to integrate in vertical strips, so there is only one case. Specifically,

$$|X - Y| \le 5 \iff -5 \le Y - X \le 5 \iff X - 5 \le Y \le X + 5.$$ Now since $$-15 \le X \le 15$$, it follows that $$-30 < -20 \le Y \le 20 < 30$$ and there is no additional casework. We get

\begin{align} \Pr[|X-Y| \le 5] &= \frac{1}{1800} \int_{x=-15}^{15} \int_{y=x-5}^{x+5} 1 \, dy \, dx \\ &= \frac{1}{1800} \int_{x=-15}^{15} (x+5) - (x-5) \, dx \\ &= \frac{1}{180} \int_{x=-15}^{15} 1 \, dx \\ &= \frac{1}{180} (30) \\ &= \frac{1}{6}. \end{align}

For completeness' sake, if we were to do it your way, how would it work? We would need to write

\begin{align} \Pr[|X-Y| \le 5] &= \frac{1}{1800} \left( \int_{y=-20}^{-10} \int_{x=-15}^{y+5} 1 \, dx \, dy + \int_{y=-10}^{10} \int_{x=y-5}^{y+5} 1 \, dx \, dy + \int_{y=10}^{20} \int_{x=y-5}^{15} 1 \, dx \, dy \right). \\ \end{align}

Contrast this with what you wrote in your solution. The error arises from the fact that when $$Y < -20$$ or $$Y > 20$$, there is no $$X$$ in the range $$[-15,15]$$ that allows both people to meet within $$5$$ minutes of each other. That is why your probability is smaller than $$1/6$$--the value of the integrals in those regions you have included is negative.

• Thank you. Your response makes things clear for me :) Commented Jun 10, 2022 at 9:20