# Finding $P(X < Y)$ where $X$ and $Y$ are independent uniform random variables

Suppose $X$ and $Y$ are two independent uniform variables in the intervals $(0,2)$ and $(1,3)$ respectively. I need to find $P(X < Y)$.

I've tried in this way: $$\begin{eqnarray} P(X < Y) &=& \int_1^3 \left\{\int_0^y f_X(x) dx\right\}g_Y(y) dy\\ &=& \frac{1}{4} \int_1^3 \int_0^y dx dy\\ &=& \frac{1}{4} \int_1^3 y dy\\ &=& \frac{1}{8} [y^2]_1^3\\ &=& 1 \end{eqnarray}$$ But I'm suspicious about this result. It implies that $X<Y$ is a sure event, which is not at all true.

This sketch might help. You want the red area as a proportion of the red and blue areas. • This question was given as a multiple choice question, so I stick to the graphical way of solution. Thanks :) Jul 27, 2015 at 9:11

\begin{align} \mathsf P(X < Y) &=\int_1^3 \left\{\int_0^y f_X(x) \operatorname dx\right\}g_Y(y) \operatorname dy\\ &\neq \tfrac{1}{4} \int_1^3 \int_0^y \operatorname dx \operatorname dy \end{align} Here's the problem.   The inner integral's upper bound should be $\min(2, y)$ because the support for $X$ is $(0;2)$.   Watch out for this.

\begin{align} \mathsf P(X < Y) &= \tfrac{1}{4} \int_1^3 \int_0^{\min(2,y)} \operatorname dx \operatorname dy \\& = \tfrac 1 4 \left(\int_1^2\int_0^y\operatorname d x\operatorname d y + \int_2^3\int_0^2 \operatorname dx \operatorname d y\right) \\& =\tfrac 1 4\left({\int_1^2 y\operatorname d y+\int_2^3 2 \operatorname d y }\right) \\& =\tfrac 1 4\left(\tfrac 1 2(2^2-1^2)+ 2(3-2)\right) \\& =\tfrac 7 8 \end{align}

That is all.

• Please correct your code, I'm not seeing any mathematics...only code...may be there is a rendering error Jul 27, 2015 at 9:14

If you want to solve the problem using integrals then you should notice that you have wrong upper limit in the inner integral. It should be min(y,2).

We .can draw the rectangle and it's interior $0 \leq x \leq 2$ and $1 \leq y \leq 3$. Then we can draw the line $y=x$. Let's look at our event. So we should draw the line $y=x$. Now, the region delimited is given by the triangle whose vertices are $(1,1)$, $(2,2)$ and $(2,1)$.The probanility is $\int\limits_{1}^{2}\int\limits_{1}^{x} \frac{1}{4}dydx$.

Split the inteval and use Baye's Theorem to get

$$P(X<Y) = P(X<Y | X<1) P(X<1) + P(X<Y|X\geq1)P(X\geq 1))$$

sind $X$ is uniform on $(0,2)$, we know that $P(X<1)=P(X>1) = \frac12$. Furthermore, $P(X<Y|X<1) = 1$ since $Y$ is uniform on $(1,3)$. This yields $$P(X<Y) = 1 \cdot \frac12 + P(X<Y|X\geq1)\frac12$$

Now $P(X<Y| X\geq 1) = P(X'<Y)$ where $X'$ is $\mathcal{U}(1,2)$. We can again split this and use Baye's to \begin{align}P(X'<Y) &= P(X'<Y| Y<2)P(Y<2) + P(X'<Y| Y\geq 2)P(Y\geq2) \\ &= P(X'<Y|Y<2)\frac12 + 1\cdot \frac12 \end{align} Now $P(X'<Y|Y<2) = P(X'<Y')$ with $Y'$ uniform in $(1,2)$. Since also $X$ is uniform in $(1,2)$, we have $P(X'<Y') = \frac12$.

Bringing everything together we obtain \begin{align} P(X<Y) = \frac12 + \left(\frac14+\frac12\right)\frac12 =\frac78 \end{align}

• Step wise solution !...thanks. Jul 27, 2015 at 9:12

Divide the regions of X with respect to Y for the condition $X<Y$.
For $0<X<1$, $P(X<Y) = \frac{1}{2}$
For $1<X<2$ and $1<Y<2$ $P(X<Y) = \int_{1}^{2}\int_{x}^{2} \frac{1}{2}\frac{1}{2}dydx = \frac{1}{8}$
For $1<X<2$, and $2<Y<3$ $P(X<Y) = \frac{1}{2}.\frac{1}{2}=\frac{1}{4}$
Thus $P(X<Y) = \frac{1}{2}+ \frac{1}{8}+\frac{1}{4} = \frac{7}{8}$