A probability problem with two uniformly distributed random variables

Please consider the following problem and my soltuion to it. I would like to know where I went wrong.
Thanks,
Bob

Problem:
Let $$X$$ and $$Y$$ be independent random variable each uniformly distributed on $$(0,1)$$. Find $$P(|\frac{x}{y}-1|\leq .5)$$.
$$\begin{eqnarray*} \Big|\frac{x}{y}-1\Big|\leq .5 &\iff& -0.5 \leq \frac{x}{y} -1 \leq 0.5 \\ P\Big(\Big|\frac{x}{y}-1 \Big| \leq .5\Big) &=& P\Big(\frac{x}{y}-1 \leq .5\Big) - P\Big(1 - \frac{x}{y} \leq -.5\Big) \\ P\Big(\Big|\frac{x}{y}-1 \Big| \leq .5\Big) &=& P\Big(\frac{x}{y}-1 \leq .5\Big) - P\Big(\frac{x}{y} - 1 \geq 0.5\Big) \\ % P\Big(\frac{x}{y}-1 \leq .5\Big) &=& P\Big(\frac{x}{y} \leq 1.5\Big) = P( x \leq 1.5y ) \\ P\Big(\frac{x}{y}-1 \leq .5\Big) &=& \int_0^1 \int_{0}^{1.5y} 1 \,\, dx \,\, dy \\ P\Big(\frac{x}{y}-1 \leq .5\Big) &=& \int_0^1 1.5y \,\, dy = \frac{3y^2}{4} \Big|_0^1 \\ P\Big(\frac{x}{y}-1 \leq .5\Big) &=& \frac{3}{4} \\ \end{eqnarray*}$$ Now we need to find $$P\Big(\frac{x}{y} - 1 \geq 0.5\Big)$$ $$\begin{eqnarray*} P\Big(\frac{x}{y} - 1 \geq 0.5\Big) &=& 1 - P\Big(\frac{x}{y} - 1 \leq 0.5\Big) \\ P\Big(\frac{x}{y} - 1 \leq 0.5\Big) &=& P\Big(\frac{x}{y} - \leq 1.5\Big) = P( x \leq 1.5y ) \\ P( x \leq 1.5y ) &=& \int_0^1 \int_0^{1.5y} \, dx \,\, dy = \int_0^1 \frac{3y}{2} dy \\ P( x \leq 1.5y ) &=& \frac{3y^2}{4} \Big|_0^1 = \frac{1}{4} \\ P\Big(\frac{x}{y} - 1 \geq 0.5\Big) &=& 1 - \frac{3}{4} = \frac{1}{4} \\ P\Big(\Big|\frac{x}{y}-1 \Big| \leq .5\Big) &=& \frac{3}{4} - \frac{1}{4} \\ P\Big(\Big|\frac{x}{y}-1 \Big| \leq .5\Big) &=& \frac{1}{2} \\ \end{eqnarray*}$$
However, the book's answer is: $$\frac{5}{12}$$.

• $P(x\le 1.5y)$ should be $P(x\le min(1.5y,1))$. – herb steinberg Oct 8 '18 at 19:15
• $\frac{1}{2}$ is the answer you get when you ignore the fact that $0\le x\le 1$. – herb steinberg Oct 9 '18 at 3:20

$$-0.5\le \frac{x}{y}-1\le 0.5$$ or $$-0.5y\le x-y\le 0.5y$$ or $$0.5y\le x\le 1.5y$$. The probability is $$P=\int_0^1 \int_{.5y}^{min (1,1.5y)}dxdy=\int_0^\frac{2}{3}ydy+\int_{\frac{2}{3}}^1(1-.5y)dy=\frac{5}{12}$$.

Note: answer is different from book.

• I did a simulation; your answer looks right. – J.G. Oct 9 '18 at 6:26
• @J.G. What was the sample size for the simulation? – herb steinberg Oct 9 '18 at 16:14
• @herb.steinberg $10,000$; its estimate was $0.4167$. – J.G. Oct 9 '18 at 16:19
• Standard deviation is approximately $0.005$ so $\frac{3}{8}$ is definitely ruled out. – herb steinberg Oct 9 '18 at 21:50
• $\frac{5}{12}$ = 0.4166666666666..... – herb steinberg Oct 10 '18 at 22:09

$$\Big|\frac{x}{y}-1\Big|\leq 0.5 \iff -0.5 \le \frac{x}{y}-1 \le 0.5$$
So it follows: \begin{align*}P\Big(\Big|\frac{x}{y}-1\Big|\leq 0.5\Big) &= P\Big(\frac{x}{y}-1\leq 0.5\Big) - P\Big(\frac{x}{y}-1\leq -0.5\Big)\\ &= P\Big(\frac{x}{y}-1\leq 0.5\Big) - P\Big(1-\frac{x}{y}\geq 0.5\Big) \\ &= P\Big(\frac{x}{y}-1\leq 0.5\Big) - 1 + P\Big(1-\frac{x}{y}\leq 0.5\Big)\end{align*}
• There is no change in your post. Consider the additional "-1" in my equation.Then it holds \begin{align*}P\left(\frac{x}{y} - 1 \le 0.5\right) &= P(x \le 1.5y)\\ &= \int_0^1\int_0 ^\min(1,1.5y) dx dy\\ &= \frac{2}{3}\end{align*} and \begin{align*}P\left(1 - \frac{x}{y} \le 0.5\right) &= P(0.5y \le x)\\ &= \int_0^1\int_{0.5y} ^1 dx dy\\ &= \frac{3}{4}\end{align*} and so we get $$P\Big(\Big|\frac{x}{y}-1\Big|\leq 0.5\Big) = \frac{2}{3} - 1 + \frac{3}{4} = \frac{5}{12}$$ like herb steinberg already calculated. – Gono Oct 9 '18 at 15:45