Library · Geometric Probability · Chapter 34

Expected distance from a random point in a square to its centre

Revised Report an error

Problem 34.1

A point PP is chosen uniformly at random in the unit square [−12,12]2[-\tfrac12, \tfrac12]^2. What is the expected distance from PP to the centre of the square?

Solution. With the centre at the origin, the expected distance is E[∣P∣]=∫−1/21/2∫−1/21/2x2+y2 dx dy.\mathbb{E}[|P|] = \int_{-1/2}^{1/2} \int_{-1/2}^{1/2} \sqrt{x^2 + y^2} \, dx \, dy.

By symmetry, restrict to the first quadrant and multiply by 44: E[∣P∣]=4∫01/2∫01/2x2+y2 dx dy.\mathbb{E}[|P|] = 4 \int_0^{1/2} \int_0^{1/2} \sqrt{x^2 + y^2} \, dx \, dy.

Use polar coordinates in the first quadrant. The square [0,1/2]2[0, 1/2]^2 breaks into two regions by the diagonal y=xy = x. In the lower triangle (0≤y≤x≤1/20 \leq y \leq x \leq 1/2) the angle θ\theta runs in [0,π/4][0, \pi/4] and the radius goes from 00 to 1/(2cos⁡θ)1/(2 \cos \theta). By symmetry, the upper triangle contributes the same integral. E[∣P∣]=8∫0π/4 ⁣ ⁣∫01/(2cos⁡θ) ⁣ ⁣r2 dr dθ=8∫0π/413⋅18cos⁡3θ dθ=13∫0π/4sec⁡3θ dθ.\begin{align*} \mathbb{E}[|P|] &= 8 \int_0^{\pi/4} \!\! \int_0^{1/(2\cos\theta)} \!\! r^2 \, dr \, d\theta \\ &= 8 \int_0^{\pi/4} \frac{1}{3} \cdot \frac{1}{8 \cos^3 \theta} \, d\theta = \tfrac{1}{3} \int_0^{\pi/4} \sec^3 \theta \, d\theta. \end{align*}

The standard integral is ∫sec⁡3θ dθ=12[sec⁡θtan⁡θ+ln⁡∣sec⁡θ+tan⁡θ∣]\int \sec^3 \theta \, d\theta = \tfrac{1}{2}\big[ \sec \theta \tan \theta + \ln|\sec \theta + \tan \theta| \big]. Evaluating from 00 to π/4\pi/4: ∫0π/4sec⁡3θ dθ=12[2⋅1+ln⁡(2+1)]−0=2+ln⁡(1+2)2.\int_0^{\pi/4} \sec^3 \theta \, d\theta = \tfrac12 \big[ \sqrt{2} \cdot 1 + \ln(\sqrt{2} + 1) \big] - 0 = \tfrac{\sqrt{2} + \ln(1 + \sqrt{2})}{2}.

Hence E[∣P∣]=2+ln⁡(1+2)6≈0.3826.■\boxed{\mathbb{E}[|P|] = \frac{\sqrt{2} + \ln(1 + \sqrt{2})}{6} \approx 0.3826.} \qedhere

Expected distance from a uniform random point in the unit square to its centre. Points (rose) sampled in the square, with their distances |P| illustrated by copper segments to the centre. The average distance evaluates to (\sqrt 2 + \ln(1+\sqrt 2))/6 \approx 0.3826 .
Expected distance from a uniform random point in the unit square to its centre. Points (rose) sampled in the square, with their distances ∣P∣|P| illustrated by copper segments to the centre. The average distance evaluates to (2+ln⁡(1+2))/6≈0.3826(\sqrt 2 + \ln(1+\sqrt 2))/6 \approx 0.3826.

The like-for-like comparison is a uniform point in a disc of radius 12\tfrac12 and its distance to the centre, whose mean is 2R3=13≈0.333\tfrac{2R}{3} = \tfrac13 \approx 0.333. The square value (2+ln⁡(1+2))/6≈0.3826(\sqrt2 + \ln(1+\sqrt2))/6 \approx 0.3826 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
Report an error on this page

Reports are stored by Netlify. See the privacy note.