Suppose I have a line segment of length L. I now select two points at random along the segment. What is the expected value of the distance between the two points, and why?

**Answer**

Byron has already answered your question, but I will attempt to provide a detailed solution…

Let X be a random variable uniformly distributed over [0,L], i.e., the probability density function of X is the following

fX(x)={1Lifx∈[0,L]0otherwise

Let us randomly pick two points in [0,L] *independently*. Let us denote those by X1 and X2, which are random variables distributed according to fX. The distance between the two points is a new random variable

Y=|X1−X2|

Hence, we would like to find the expected value E(Y)=E(|X1−X2|). Let us introduce function g

g(x1,x2)=|x1−x2|={x1−x2ifx1≥x2x2−x1ifx2≥x1

Since the two points are picked independently, the joint probability density function is the product of the pdf’s of X1 and X2, i.e., fX1X2(x1,x2)=fX1(x1)fX2(x2)=1/L2 in [0,L]×[0,L]. Therefore, the expected value E(Y)=E(g(X1,X2)) is given by

E(Y)=∫L0∫L0g(x1,x2)fX1X2(x1,x2)dx1dx2=1L2∫L0∫L0|x1−x2|dx1dx2=1L2∫L0∫x10(x1−x2)dx2dx1+1L2∫L0∫Lx1(x2−x1)dx2dx1=L36L2+L36L2=L3

**Attribution***Source : Link , Question Author : Kenshin , Answer Author : Michael Hardy*