# Mathematical expectation of the average distance of some set of points

In cartesian plane, $$N$$ points are randomly generated within a unit square defined by points $$(0,0) (0,1) (1,1) (1,0)$$, with uniform distribution. What is the mathematical expectation of the average distance of all distances between all points (distances between the point and the same point (which are obviously $$0$$) are excluded from the calculation of the average).

There are actually two versions of this question:

1. Distance is defined as Euclidian.
2. Distance is defined as Manhattan.

The context of this question is some performance benchmarking in computer science, which are of practical nature and far from pure mathemathics, so I am not going the bother the reader with these details.

• About the first part, Euclidean distance: presumably all the points are independent to each other, then this $N$ point version is equivalent to just two-points, since you're taking unweighted average of all the expectations. – Lee David Chung Lin Feb 14 at 13:40
• For Euclidean distance, I get $$\int_0^1\int_0^1\int_0^1\int_0^1\sqrt{(x-w)^2+(y-z)^2}\mathrm{d}w\mathrm{d}x\mathrm{d}y\mathrm{d}z$$ Is there an easy way to do this? – saulspatz Feb 14 at 14:08
• Simulation with $10^6$ trials gave $0.52138263$ for Euclidean distance. For Manhattan distance, the average distance is twice the average horizontal distance, so it's easy. – saulspatz Feb 14 at 14:22

$$\Bbb E\left(\frac{1}{\binom N2}\sum_{1\leqslant i < j \leqslant N} d(P_i,P_j)\right);$$
$$\frac1{\binom N2}\sum_{1\leqslant i < j \leqslant N} \Bbb E\big(d(P_i,P_j)\big).$$
By (assumed) independence of the distribution of the points $$P_i$$, $$\Bbb E\big(d(P_i,P_j)\big)$$ is the same for all pairs $$i\neq j$$. Do you think you can take it from here?
• Small comment. Shouldn't it be $j \leq N$ and not $j \leq 4$ under the sigma? – roundsquare Feb 15 at 23:49