Artificial intelligent assistant

Mean distance between N equidistributed points in a circle I would like to calculate the mean distance depending on circle shape points, This is a mean for calculating **all possible distances between any two points** for $N=2$, line, there is only 1 distance. for $N=3$, triangle, again, there is only 1 distance for $N=4$, square, henceforth there are more than 1 distance.. in this case we would have four distances for sides and two distances in diagonal path, $\sqrt{2}$, then the mean distance would be $D=(4+2\sqrt{2})/6=1.138..$ for $N=30$, it would be a "pixeled" circle .. and $N=\infty$ is a circle How to calculate it for $N>4$ ? Is there any general formula or can it be derived? Thanks!

The average distances among all points must be equal that the average distances from a given point. By geometry: we have that the distance is $d=2 \sin(\theta/2)$, so:

$$\bar d = \frac{2}{N-1} \sum_{k=1}^{N-1} \sin\left(\frac{\pi k}{N}\right)$$

On the limit, $N\to \infty$, you replace the sum by an integral and you get the limit by Christian Blatter: $\bar d \to 4/ \pi$

For example, for $N=30$:


>>> N=30;
>>> r = 2* sin(pi*[1:N-1]/(N));
>>> sum(r)/(N-1)
ans = 1.3159
>>> 4/pi
ans = 1.2732


_Update_ : If instead of having a unit circle (radius 1) we have that the distance among nearest neighbours is 1 (the question is not clear about this, and the example for N=4 only makes sense in this later case), we just divide the above result by $2\; \sin(\pi/N)$. In the limit, $\sin(\pi/N) \to \pi/N$ and so $\bar d \to N \; 2/\pi^2$

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy a233c8515a514fb7dfc59af1d3ff93d1