A square with side $a$ is given. What is the average distance between two uniformly-distributed random points inside the square?

For more general "rectangle" case, see here. The proof found there is fairly complex, and I am looking for a simpler proof for this special case. I expect it could be significantly simpler.

See also "line" case.


1 Answer 1


We just have to compute: $$ I=\int_{[0,1]^4}\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}\,d\mu. \tag{1}$$ Assuming that $X_1$ and $X_2$ are two independent random variables, uniformly distributed over $[0,1]$, the pdf of their difference $\Delta X=X_1-X_2$ is given by: $$ f_{\Delta X}(x) = \left(1-|x|\right)\cdot\mathbb{1}_{[-1,1]}(x)\tag{2}$$ hence: $$\begin{eqnarray*} I &=& \iint_{[-1,1]^2}(1-|x|)(1-|y|)\sqrt{x^2+y^2}\,dx\,dy \\&=&4\iint_{[0,1]^2}xy\sqrt{(1-x)^2+(1-y)^2}\,dx\,dy\tag{3}\end{eqnarray*}$$ that is tedious to compute but still possible; we have:

$$ I = \frac{2+\sqrt{2}+5\operatorname{arcsinh}(1)}{15}=\frac{2+\sqrt{2}+5\log(1+\sqrt{2})}{15}=0.52140543316472\ldots$$

(OEIS A091505)

hence the average distance between two random points in $[0,a]^2$ is around the $52.14\%$ of $a$.

  • $\begingroup$ Does this variable $I$ have a name? I believe I have seen it before used as a named constant. $\endgroup$
    – esote
    Nov 14, 2016 at 3:55
  • 4
    $\begingroup$ 3D version is called Robbins constant, not sure 2D version has a name. en.wikipedia.org/wiki/Robbins_constant $\endgroup$
    – karakfa
    Feb 14, 2018 at 16:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .