# What's the probability of choosing two numbers from $[0,1]$ and having the difference at least one half?

We have the unit interval $[0,1]$ and we want to find the probability of picking two random numbers $a,b$ from that interval with $|a-b|>0.5$.

Must I investigate $[0,1]×[0,1]$?

I don't have the faintest idea of how to solve this. The problem is that $[0,1]$ has infinite numbers to pick from… so how to calculate a probability with infinitely many items in the sample space?

I would be really happy if somebody shed a light on this.

• I think you're using the word "possibility" where you want to use "probability". – G Tony Jacobs Feb 19 '18 at 14:55
• $a,b$ follows what distribution? They are iid uniformly distributed on $[0,1]$? – GNUSupporter 8964民主女神 地下教會 Feb 19 '18 at 14:55
• $|a-b|>0.5 \implies a > b+0.5$ or $a<b-0.5$. – Math Lover Feb 19 '18 at 14:55
• Occam's razor is not infallible, but it suggests that if someone talks about choosing numbers "randomly" from an interval, without specifying a distribution, then they are probably thinking of the uniform distribution. Before I knew about different distributions, that's what I would have meant. – G Tony Jacobs Feb 19 '18 at 15:05
• @KwnstantinosNikoloutsos it might help you to check the "Line Line Picking problem": I could be wrong but it seems to handle exactly that type of problem regarding the probability of the distance... mathworld.wolfram.com/LineLinePicking.html – iadvd Feb 20 '18 at 5:01

Quick, draw a diagram!

Since the two random variables are independent and uniformly distributed, the answer is clearly $\frac14$.

• Thanks for providing the illustration that was missing from my answer! :) – G Tony Jacobs Feb 19 '18 at 14:55
• It's worth noting that it's not stated that $a,b$ are uniformly distributed, but as long as they are independent, your approach will work with a slight modification in the integral. – GNUSupporter 8964民主女神 地下教會 Feb 19 '18 at 14:57
• So if I have a problem with 3 random variables, then should I use a 3-dimensional cube? – Kwnstantinos Nikoloutsos Feb 19 '18 at 15:22
• @KwnstantinosNikoloutsos Yes (as long as the variables are iid uniform). And so on for higher dimensions, though you'd be resorting to integration by then. – Parcly Taxel Feb 19 '18 at 15:23
• @Parcly Taxel I love your "proof by picture". I always encourage picture drawing. What comes next is having the student draw the picture on the board and discussing why some points in [0, 1] x [0, 1] work and others don't. Vary the problem by making the "required distance" a parameter. Then discuss different "limiting behavior". Pictures like these open doors for a wide variety of topics from basic counting to calculus and the probability you'll land in between! – David Dyer Feb 26 '18 at 19:31

The geometric approach works well here. If you choose two points uniformly from the interval $[0,1]$, that's the same as choosing a point uniformly from the square with vertices $(0,0), (0,1), (1,0)$ and $(1,1)$. Now, you can graph the lines corresponding to the conditions $y=x+\frac12$ and $y=x-\frac12$. Between those lines are points where the difference between $x$ and $y$ is less than $\frac12$, and outside of them, you find points where the difference is greater. Use geometry to calculate the area inside your square of interest, but not between those two lines. That's your answer, since the total area of the square is $1$.

• I feel like this answer should be tacked onto the accepted one and you should both be considered as answerers. – user1717828 Feb 19 '18 at 17:43
• It's funny: we answered nearly simultaneously. I understand the preference, though. Pictures are great when they can convey an idea so elegantly. The first time I saw such a demonstration, my mind was pleasantly blown. – G Tony Jacobs Feb 19 '18 at 17:44

Note: $$|a-b|>0.5 \Rightarrow a>b+0.5 \ \ \ \text{or} \ \ \ a<b-0.5.$$ Considering $0\le a,b\le 1$ we get: $$\begin{cases} b+0.5<a\le 1 \\ 0\le b<0.5 \end{cases} \ \ \ \text{or} \ \ \ \begin{cases} 0\le a <b-0.5 \\ 0.5<b\le 1\end{cases}.$$ We make up double integrals: $$P=\int_0^{0.5} \int_{b+0.5}^1 \mathrm{d}a \, \mathrm{d}b\color{red}{+}\int_{0.5}^1 \int_0^{b-0.5} \mathrm{d}a \, \mathrm{d}b=$$ $$\int_0^{0.5} (0.5-b)\, \mathrm{d}b \color{red}{+} \int_{0.5}^1 (b-0.5)\, \mathrm{d}b=$$ $$0.25-0.125 \color{red}{+} 0.5-0.125-0.5+0.25=0.25.$$

• This generalises well to higher dimensions, but I think it's just simpler to draw a diagram when there are only $2$ variables, and the diagram is in 2D. – Toby Mak Feb 20 '18 at 4:59
• @TobyMak, agreed the graphical method is easier to imagine, yet the algebraic method is also important (especially, for publishing in journals and for making it more rigorous). – farruhota Feb 20 '18 at 5:21