Library · Geometric Probability · Chapter 33

Expected distance on a segment

Revised Report an error

Problem 33.1

Let X,YX, Y be two points chosen independently and uniformly on the unit segment [0,1][0,1]. What is the expected distance E[∣X−Y∣]\mathbb{E}[|X - Y|]?

Solution. By symmetry, condition on X<YX < Y (the event has probability 12\tfrac12). In this case, ∣X−Y∣=Y−X|X - Y| = Y - X. Compute directly: E[Y−X∣X<Y]=112∫01∫0y(y−x) dx dy=2∫01y22 dy=13.\mathbb{E}[Y - X \mid X < Y] = \frac{1}{\tfrac12} \int_0^1 \int_0^y (y - x) \, dx \, dy = 2 \int_0^1 \frac{y^2}{2} \, dy = \frac{1}{3}. By symmetry between XX and YY, the conditional expectation is the same given X>YX > Y, so E[∣X−Y∣]=13.■\boxed{\mathbb{E}[|X - Y|] = \tfrac13.} \qedhere

Alternatively, think of the three pieces of a stick snapped at two uniform points: they have lengths X(1),X(2)−X(1),1−X(2)X_{(1)}, X_{(2)} - X_{(1)}, 1 - X_{(2)}, where X(1)=min⁡(X,Y)X_{(1)} = \min(X,Y) and X(2)=max⁡(X,Y)X_{(2)} = \max(X,Y). The middle piece has length ∣X−Y∣|X - Y|, and by symmetry among the three order statistics each piece has expected length 13\tfrac13. The answer 13\tfrac13 is therefore just the equality of the three expected part-lengths.

This constant turns up in many places in geometric probability. We have already seen it in Chapter 32 as a factor of 19\tfrac19, and the higher moments E[∣X−Y∣k]\mathbb{E}[|X-Y|^k] play a role in other classical computations.

import numpy as np
x, y = np.random.rand(2, 10**7)
print(f"sim: {np.abs(x-y).mean():.5f}   exact: {1/3:.5f}")
# sim: 0.33333   exact: 0.33333
Report an error on this page

Reports are stored by Netlify. See the privacy note.