An ambulance travels back and forth at a constant speed along a road of length $L$. At a certain moment of time, an accident occurs at a point uniformly distributed on the road.[That is, the distance of the point from one of the fixed ends of the road is uniformly distributed over ($0$,$L$).] Assuming that the ambulance's location at the moment of the accident is also uniformly distributed, and assuming independence of the variables, compute the distribution of the distance of the ambulance from the accident.
Here is what I have so far:
$X$ = point where the accident happened
$Y$ = location of the ambulance at the moment.
$D = |X-Y|$, represents the distance between the accident and the ambulance
$P(D \leq d) = $$\mathop{\int\int}_{(x,y)\epsilon C} f(x,y) dx dy$
where $C$ is the set of points where $|X-Y| \leq d$
I'm having trouble setting up the limit for the integral. It would be greatly appreciated if someone can upload a picture of the area of integration.
Here is a rough sketch of the integration region:
The $x$ and $y$ axes goes between $0$ and $L$. The "shaded" (for lack of a better word) region represents those $X$ and $Y$ such that $|X-Y| \le d$.
The integration region is split in 3 pieces, which I hope you can see from this admittedly crude diagram:
$$P(|X-Y| \le d) = \frac{1}{L^2} \left [\int_0^d dx \: \int_0^{d+x} dy + \int_d^{L-d} dx \: \int_{-d+x}^{d+x} dy + \int_{L-d}^{L} dx \: \int_{-d+x}^{L} dy \right ]$$
So you can check, the result I get is
$$P(|X-Y| \le d) = \frac{d}{L} \left ( 2 - \frac{d}{L} \right)$$
You can also see it from the difference between the area of the whole region minus the area of the 2 right triangles outside the "shaded" region.