Library · Geometric Probability · Chapter 34
Expected distance from a random point in a square to its centre
Problem 34.1
A point is chosen uniformly at random in the unit square . What is the expected distance from to the centre of the square?
Solution. With the centre at the origin, the expected distance is
By symmetry, restrict to the first quadrant and multiply by :
Use polar coordinates in the first quadrant. The square breaks into two regions by the diagonal . In the lower triangle () the angle runs in and the radius goes from to . By symmetry, the upper triangle contributes the same integral.
The standard integral is . Evaluating from to :
Hence
The like-for-like comparison is a uniform point in a disc of radius and its distance to the centre, whose mean is . The square value is larger because the square has corners lying farther from the centre than any point of the inscribed disc. (One should not compare this single-point, point-to-centre distance with a two-point chord length of a circle: those are different quantities.)
import numpy as np
# Uniform in [-0.5, 0.5]^2; measure distance to centre (origin).
pts = np.random.rand(2, 10**7) - 0.5
d = np.sqrt(pts[0]**2 + pts[1]**2)
exact = (np.sqrt(2) + np.log(1 + np.sqrt(2))) / 6
print(f"sim: {d.mean():.5f} exact: {exact:.5f}")
# sim: 0.38256 exact: 0.38260