How can I compute this probability? I do not know what to do since it involves two random variables.
Let $X$ and $Y$ be uniform random variables on $(0,1)$. How can I compute this?
$$ P(|X-Y| < 0.25). $$
I tried to do it using an integral $$ \int_0^1 P(|X-y| < 0.25) \,dy $$
but I do not know what to do next.
edit: I forgot to mention the independence of the random variables. Thanks for warning.
To accompany André's: answer:
Note $$|Y-X|\le {1\over4}\iff\ \color{darkgreen}{ X-{1\over 4}}\le\ Y\le \color{maroon}{X+{1\over4}}.$$
As André makes clear in his answer, you need to compute $$ \int\kern-4pt\int_A 1 dy\,dx $$ where $A$ is the pink region above. The best way to do this directly, if unimaginatively (see the end of André's comment below), is to split $A$ into three pieces:
and integrate over each piece; then, add the three integrals together.
Let's set up the double integral over the light green region:
You can imagine that the light green region is generated as the line $\color{darkgreen}{\ell_x}$ sweeps across the region starting at $x=1/4$ and ending at $x=3/4$. The limits of integration for the inner integral will be from the bottom of $\ell_x$ (namely $x-1/4$) to the top of $\ell_x$ (namely $x+1/4$). Here, we integrate with respect to $y$ (we "add function values over the line $\ell_x$"): $$ \int_{x-1/4}^{x+{1/4}} 1\,dy. $$ Now we integrate the above expression with respect to $x$ as $\ell_x$ ranges from its leftmost value $x=1/4$ to its right most value $x=3/4$: $$ \int_{1/4}^{3/4}\int_{x-1/4}^{x+{1/4}} 1\,dy\,dx. $$
So, that's the integral over the light green region.
I'll leave it you you to evaluate the integral and to set up and evaluate the integrals for the other two regions (but if you need help, please ask).