Mean Distance between Two Random Points in Cuboid

Theorem
Let $B$ be a cuboid in the Cartesian $3$-space $\R^3$ as:
 * $\size x \le a$, $\size y \le b$, $\size z \le c$

Let $E$ denote the mean distance $D$ between $2$ points chosen at random from the interior of $B$.

Then:

where:

Proof
Let $X_1$, $X_2$; $Y_1$, $Y_2$; $Z_1$, $Z_2$ be pairs of independent random variables with a continuous uniform distribution in $\closedint {-a} a$, $\closedint {-b} b$ and $\closedint {-c} c$.

The random variables $U = \size {X_1 - X_2}$, $V = \size {Y_1 - Y_2}$, $W = \size {Z_1 - Z_2}$ are likewise independent.

Thus the probability density functions $\map f U$, $\map g V$, $\map h W$ can be shown to be:

Hence the sought expectation is given by:


 * $E = \ds \dfrac 1 {8 a^2 b^2 c^2} \int_0^{2 c} \int_0^{2 b} \int_0^{2 a} \sqrt {u^2 + v^2 + v^2} \paren {2 a - u} \paren {2 b - v} \paren {2 c - w} \rd u \rd v \rd w$

Let $\map P {a, b, c}$ be the pyramid defined by the planes $u = 2 a$, $v = 0$, $w = 0$, $a v = b u$ and $a w = c u$.

Set:


 * $\map F {a, b, c} = \ds \dfrac 1 {8 a^2 b^2 c^2} \iiint_{\map P {a, b, c} } \sqrt {u^2 + v^2 + v^2} \paren {2 a - u} \paren {2 b - v} \paren {2 c - w} \rd u \rd v \rd w$

By symmetry:


 * $\map F {a, b, c} = \map F {a, c, b}$

and so:


 * $(1): \quad E = \dfrac 1 {8 a^2 b^2 c^2} \paren {\map F {a, b, c} + \map F {c, a, b} + \map F {b, c, a} }$

All that remains is to calculate $\map F {a, b, c}$.

Using spherical coordinates we obtain:

$\map F {a, b, c} = \ds \int_0^{\arctan \frac b a} \int_{\arccot \frac c a \cos \theta}^{\frac \pi 2} \int_0^{2 a \cosec \phi \sec \theta} \Phi \rd \rho \rd \phi \rd \theta$

where:
 * $\Phi = \rho^3 \paren {2 a - \rho \sin \phi \cos \theta} \paren {2 b - \rho \sin \phi \sin \theta} \paren {2 c - \rho \cos \phi} \sin \phi$

After integration:

where:

Substituting in $(1)$ we obtain: