Q:

Probability of difference of random variables

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.

A:

Hint: In order to compute an answer, you will have to make an assumption. One natural one is that $X$ and $Y$ are independent.  Perhaps that was included in the question, and you forgot to mention it. Or perhaps it was (by mistake) left out.
Assuming independence, the pair $(X,Y)$ has uniform distribution on the square. So the joint density function is $1$ in the square, and $0$ outside.
The answer is then
$$\iint_A 1\,dy\;dx,$$
where $A$ is the part of the square where $|x-y|<0.25$, or if you wish, $\le 0.25$, it makes no difference to the answer.
We can now do the integration, maybe by expressing our double integral as an iterated integral.  But there is a much simpler way to solve the problem. We are integrating $1$ over $A$, so the result is the area of $A$.
Draw the region $A$ carefully. After you do that,  you will not find it difficult to find its area. No integration, just basic geometry.
Remark: To see that we need some sort of assumption about $X$ and $Y$, let $X$ be uniformly distributed on $(0,1)$, and let $Y=X$. Then $X$ and $Y$ satisfy the conditions of the problem as stated, but are very much not independent. It is clear that $P(|X-Y|<0.25)=1$.  

A:

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).  

