Probability that the distance between two random points on a line segment $L$ is less than $kL$, where $0I have this question and I can not solve.
Suppose I have a line segment of length $L$. I now select two points at random along the segment. What is the probability that the distance between the two points is less than kL, where $0<k<L$?
I have the answer which is:
$$1-(1-k)^2$$
but I don't understand why?
Can you please help.
 A: HINT: let $X$ and $Y$ two independent and uniformly distributed random variables in $[0,L]$. Then the probability that you want is $\Pr[|X-Y|<kL]$. Then you have that
$$
\begin{align*}
\Pr[|X-Y|<kL]:=&\Pr(\{\omega \in \Omega :|X(\omega )-Y(\omega )|<kL \}\\
=&\Pr(\{\omega \in \Omega :-kL< X(\omega )-Y(\omega )<kL \}\\
=&\Pr(\{\omega \in \Omega :X(\omega )\in (Y(\omega )-kL,Y(\omega )+kL) \}\\
=&\Pr(\{\omega \in \Omega :(X(\omega ),Y(\omega ))\in S \})\\=&\Pr[(X,Y)\in S]
\end{align*}
$$
where $S:=\{(x,y)\in \Bbb R ^2:x\in (y-kL,y+kL)\}$.
Now note that $(X,Y)$ is uniformly distributed in $[0,L]^2$, therefore $\Pr[|X-Y|<kL]$ is the area of $S \cap [0,L]^2$ divided by the area of $[0,L]^2$.

Alternatively you can check that if $X$ and $Y$ are independent continuous random variables then for $Z:=X-Y$ we have that
$$
F_Z(c)=\int_{\Bbb R } f_X(s)f_Y(s-c)\,\mathrm d s
$$
Therefore
$$
\begin{align*}
\Pr[|X-Y|<kL]&=\Pr[-kL<Z<kL]\\
&=\Pr[Z<kL]-\Pr[Z\leqslant -kL]\\
&=F_Z(kL)-F_Z(-kL)
\end{align*}
$$
A: Here’s a rather informal answer to the problem. Consider a bijection of choosing the two points onto a point on a plane.

The purple region represent the possible locations of $X$ and $Y$. For instance $(0.2,0.4)$ means that point $X$ has distance $0.2L$ from one end and $Y$ has $0.4L$.
Now we want $XY$ to be less than $kL$. That is essentially saying that $|x-y|<k$ in our plane, which corresponds to the blue region, i.e. a hexagon with vertices $(0,0),(0,k),(1-k,1),\ldots$. 
To calculate the probability, we then just have to find the area of the blue region divided by the purple one, and the answer of
$$1-(1-k)^2$$
follows from direct computation.
