This question already has an answer here:

Consider the unit square $S =[0,1]\times[0,1]$. I'm interested in the average distance between random points in the square.

Let $ \mathbf{a} = \left< x_1,y_1 \right>$ and $ \mathbf{b} = \left< x_2,y_2 \right>$ be random points in the unit square. By random, I mean that $x_i$ and $y_i$ are uniformly distributed on $[0,1]$.

The normal approach is to use multiple integration to determine the average value of the distance between $\mathbf{b}$ and $\mathbf{a}$. I would like to try another approach.

$\mathbf{a}$ and $\mathbf{b}$ are random vectors, and each element has known distribution. So, the vector between them also has known distribution. The difference between two uniformly random variables has triangular distribution.

So $\mathbf{c} = \mathbf{b} - \mathbf{a}$. Then, the average distance is the expectation of $\lVert \mathbf{c} \rVert$. Perhaps it would be easier to calculate the expectation of $\lVert \mathbf{c} \rVert^2$.

In any case, I am not sure how to calculate the expectation for $\lVert \mathbf{c} \rVert^2$.

Can someone guide me in the right direction?


marked as duplicate by Ross Millikan probability Jul 5 '16 at 15:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ The expectation of $||c||^2$ is indeed much easier, just use $$E[||a-b||^2] = E[(x_1-x_2)^2+(y_1-y_2)^2] = E[(x_1-x_2)^2] + E[(y_1-y_2)^2] = 2E[(x_1-x_2)^2]$$ You can use the (triangle shape) distribution of $|x_1-x_2|$ here if you know it. Assuming independence, you could also use it for the other if you define $W=|x_1-x_2|$ and $Z=|y_1-y_2|$, then $$E\left[\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}\right] = \int_w \int_z f_W(w)f_Z(z) \sqrt{w^2 + z^2}dwdz$$. $\endgroup$ – Michael Jul 5 '16 at 1:47
  • 1
    $\begingroup$ I think your index for $\bf b$ is wrong (you have $x_1$ instead of $x_2$). $\endgroup$ – Théophile Jul 5 '16 at 1:50
  • $\begingroup$ @Théophile Thanks $\endgroup$ – Demetri Pananos Jul 5 '16 at 2:01
  • 1
    $\begingroup$ mathworld.wolfram.com/HypercubeLinePicking.html $\endgroup$ – Count Iblis Jul 5 '16 at 2:05
  • $\begingroup$ @CountIblis That's perfect, thanks. $\endgroup$ – Demetri Pananos Jul 5 '16 at 2:18

This has very little to do with linear algebra. The average distance is given by the integral:

$$ I = \int_{(0,1)^4}\sqrt{(x-X)^2+(y-Y)^2}\,d\mu.$$ Given $x$ and $X$, uniformly distributed and independent over $[0,1]$, the probability density function of $(x-X)^2$ is supported on $[0,1]$ and given by $-1+\frac{1}{\sqrt{t}}$. It follows that the PDF of $(x-X)^2+(y-Y)^2$ is supported on $[0,2]$ and given by $\pi+t-4\sqrt{t}$ on the interval $[0,1]$ and by $-2-t+4\sqrt{t-1}+2\arcsin\left(\frac{2}{t}-1\right)$ on the interval $[1,2]$. That leads to:

$$ I = \int_{0}^{1}\sqrt{t}\left(\pi+t-4\sqrt{t}\right)\,dt+\int_{1}^{2}\sqrt{t}\left(-2-t+4\sqrt{t-1}+2\arcsin\left(\frac{2}{t}-1\right)\right)\,dt$$ that simplifies to: $$ I = \color{red}{\frac{2+\sqrt{2}+5\,\text{arcsinh}(1)}{15}}=0.521405433\ldots$$

Convexity arguments are enough to prove that $\frac{1}{2}<I<\frac{1}{\sqrt{3}}$ also without an explicit computation.


Not the answer you're looking for? Browse other questions tagged or ask your own question.