Library · Geometric Probability · Chapter 59

Expected distance in a ball

Revised Report an error

Problem 59.1

Let P1,P2P_1, P_2 be points chosen independently and uniformly at random in the closed unit ball in R3\mathbb{R}^3. What is the expected distance E[∣P1−P2∣]\mathbb{E}[|P_1 - P_2|]?

Solution. By rotational symmetry, condition on P1P_1 at distance rr from the origin; WLOG take P1=(0,0,r)P_1 = (0, 0, r). The marginal density of ∣P1∣|P_1| is 3r23 r^2 for r∈[0,1]r \in [0, 1] (the Jacobian of the radial-coordinate change in the unit ball). Similarly, ∣P2∣|P_2| has density 3s23 s^2 for s∈[0,1]s \in [0, 1].

For fixed r,sr, s, the angle ϕ\phi between P1P_1 and P2P_2 has density 12sin⁡ϕ\tfrac12 \sin\phi on [0,π][0, \pi] (standard spherical coordinates). Hence E[∣P1−P2∣∣r,s]=∫0πr2+s2−2rscos⁡ϕ⋅12sin⁡ϕ dϕ.\mathbb{E}[|P_1 - P_2| \mid r, s] = \int_0^{\pi} \sqrt{r^2 + s^2 - 2 r s \cos\phi} \cdot \tfrac12 \sin\phi \, d\phi. Substitute u=cos⁡ϕu = \cos\phi, so du=−sin⁡ϕ dϕdu = -\sin\phi \, d\phi: =12∫−11r2+s2−2rsu du.= \tfrac12 \int_{-1}^{1} \sqrt{r^2 + s^2 - 2 r s u} \, du. The inner integral evaluates (by the standard antiderivative ∫a−bu du\int \sqrt{a - bu} \, du) to (r+s)3−∣r−s∣36rs.\frac{(r + s)^3 - |r - s|^3}{6 r s}. For r≥sr \geq s, (r+s)3−(r−s)3=6r2s+2s3(r + s)^3 - (r - s)^3 = 6 r^2 s + 2 s^3, so the conditional expectation simplifies to E[∣P1−P2∣∣r,s]=6r2s+2s36rs=r+s23r.\mathbb{E}[|P_1 - P_2| \mid r, s] = \frac{6 r^2 s + 2 s^3}{6 r s} = r + \frac{s^2}{3 r}.

Combine over r,sr, s. By symmetry in r,sr, s, we may write E[∣P1−P2∣]=18∫01 ⁣ ⁣∫0r ⁣ ⁣(r+s23r)r2s2 ds dr,\mathbb{E}[|P_1 - P_2|] = 18 \int_0^1 \!\! \int_0^r \!\! \left( r + \tfrac{s^2}{3 r} \right) r^2 s^2 \, ds \, dr, where the factor of 1818 comes from 2⋅3⋅32 \cdot 3 \cdot 3 (22 from the r↔sr \leftrightarrow s symmetry, and 3r2⋅3s23 r^2 \cdot 3 s^2 from the two radial densities). Carry out the inner integral: ∫0r(r3s2+rs43)ds=r63+r615=2r65,\int_0^r \left( r^3 s^2 + \tfrac{r s^4}{3} \right) ds = \frac{r^6}{3} + \frac{r^6}{15} = \frac{2 r^6}{5}, the integrand being (r+s23r)r2s2=r3s2+rs43\left(r + \tfrac{s^2}{3r}\right) r^2 s^2 = r^3 s^2 + \tfrac{r s^4}{3} (keeping the r2s2r^2 s^2 density factor). Then E[∣P1−P2∣]=18⋅25∫01r6 dr=365⋅17=3635.\mathbb{E}[|P_1 - P_2|] = 18 \cdot \tfrac{2}{5} \int_0^1 r^6 \, dr = \frac{36}{5} \cdot \frac{1}{7} = \frac{36}{35}. So E[∣P1−P2∣]=3635≈1.029.■\boxed{\mathbb{E}[|P_1 - P_2|] = \frac{36}{35} \approx 1.029.} \qedhere

The closed form 3635\tfrac{36}{35} is the three-dimensional companion of the disc constant 12845π\tfrac{128}{45\pi}. The appearance of a rational number in 3D — versus a π\pi-involving number in 2D — reflects the difference in the angular integrals: in 2D the angular integral produces an elliptic integral (yielding π\pi), while in 3D the angle ϕ\phi has the simple measure sin⁡ϕ dϕ\sin \phi \, d\phi that integrates to elementary functions.

import numpy as np
# Two uniform points in unit ball via rejection sampling
def sample_ball(n):
    out = np.empty((3, n))
    filled = 0
    while filled < n:
        c = np.random.uniform(-1, 1, (3, 2*n))
        mask = (c*c).sum(axis=0) <= 1
        good = c[:, mask][:, :n-filled]
        out[:, filled:filled+good.shape[1]] = good
        filled += good.shape[1]
    return out
p1, p2 = sample_ball(10**6), sample_ball(10**6)
d = np.linalg.norm(p1 - p2, axis=0)
print(f"sim: {d.mean():.5f}   exact: {36/35:.5f}")
# sim: 1.02838   exact: 1.02857
Report an error on this page

Reports are stored by Netlify. See the privacy note.