P(X > Y - 1/2), given X and Y are uniform(0,1) I'm trying to calculate this, using the law of total probability. My understanding is that the answer should be 1/2.
$\displaystyle P\left(X > Y - \frac{1}{2}\right) = \int_{0}^{1} P\left(X > Y - \frac{1}{2} \middle| Y = y\right) \cdot f_Y(y) \cdot dy$
Solving the first term on the integral:
$\displaystyle P\left(X > Y - \frac{1}{2} \middle| Y = y\right) = 1 - F_x\left(y-\frac{1}{2}\right) = 1 - \int_{0}^{y-\frac{1}{2}} dx = \frac{3}{2} - y$
And combining it with the second:
$\displaystyle P\left(X > Y - \frac{1}{2}\right) = \int_{0}^{1} \left(\frac{3}{2} - y\right) \cdot 1 \cdot dy = 1$
Which seems incorrect.. could someone please point out what I'm missing?
 A: For $0<y<1$ we have
$$P\left(X>y-\frac{1}{2}\right)=
\begin{cases}
1 & \text{ if } y\le \frac{1}{2}\\
\frac{3}{2}-y & \text{ if } y>\frac{1}{2}
\end{cases}
$$
So
$$P\left(X>Y-\frac{1}{2}\right)=\int_0^{1/2}1\,dy+\int_{1/2}^1 \left(\frac{3}{2}-y\right) dy=\frac{1}{2}+\frac{3}{8}=\frac{7}{8}$$
A: Demonstration of this result using simulation in R statistical software,
with 100,000 realizations of $(X,Y).$
 m = 10^5;  x = runif(m);  y = runif(m)
 cond = (x > y - .5)  # logical vector of TRUEs and FALSEs
 mean(cond)           # proportion of TRUEs
 ## 0.87414           # aprx P(X > Y - 1/2)
 7/8
 ## 0.875             # exact P(X > Y - 1/2)

So the answer is not 1/2, as you speculated. In the plot below, the green
region corresponds to the desired probability. Because the joint PDF equals 1
over the unit square, the desired probability is the area of the green region
times 1. So the problem can be solved using geometry instead of calculus.
But if you insist on using (more generally applicable) calculus, then the
illustration will help you get the correct limits of integration. 

A: Another perspective: Since both random variables are uniformly distributed, you can examine the unit square with lower-left corner at the origin, and compare the area of the portion of that square for which $X > Y - 1/2$ with the area of the entire square (which is just $1$).
This will give you a graphical notion of the analytical answer given by Momo.
