Library · Geometric Probability · Chapter 10

Expected minimum distance to the boundary of a square

Revised Report an error

Problem 10.1

A point P=(X,Y)P = (X, Y) is chosen uniformly at random in the unit square [0,1]2[0, 1]^2. What is the expected minimum distance from PP to the boundary of the square?

Solution. The minimum distance from PP to the boundary is D=min⁡(X, 1−X, Y, 1−Y).D = \min(X, \, 1 - X, \, Y, \, 1 - Y). Write U=min⁡(X,1−X)U = \min(X, 1 - X) and V=min⁡(Y,1−Y)V = \min(Y, 1 - Y), so D=min⁡(U,V)D = \min(U, V).

The random variable XX is uniform on [0,1][0, 1], and U=min⁡(X,1−X)U = \min(X, 1 - X) satisfies U≤uU \leq u iff X≤uX \leq u or X≥1−uX \geq 1 - u, so P(U≤u)=2u\mathbb{P}(U \leq u) = 2u for u∈[0,12]u \in [0, \tfrac12]. Hence UU is uniform on [0,12][0, \tfrac12], with density 22. Similarly VV is uniform on [0,12][0, \tfrac12], independently of UU.

Now D=min⁡(U,V)D = \min(U, V) where U,VU, V are iid uniform on [0,12][0, \tfrac12]. For iid uniforms on [0,a][0, a], E[min⁡(U,V)]=∫0aP(min⁡>u) du=∫0a(1−ua)2du=a3.\mathbb{E}[\min(U, V)] = \int_0^a \mathbb{P}(\min > u) \, du = \int_0^a \left(1 - \tfrac{u}{a}\right)^2 du = \frac{a}{3}. With a=12a = \tfrac12: E[D]=16.■\boxed{\mathbb{E}[D] = \frac{1}{6}.} \qedhere

The same calculation in one dimension (distance from random point in [0,1][0, 1] to its nearest endpoint) gives 14\tfrac14; in three dimensions (cube) it gives 18\tfrac18; in general dimension dd it is 12(d+1)\tfrac{1}{2(d+1)}. The factor d+1d+1 arises because we take the minimum over 2d2d coordinate-distances, and folding by the midpoint makes each “half-coordinate” uniform on [0,12][0, \tfrac12].

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

Reports are stored by Netlify. See the privacy note.