# The expected distance between two points on a sphere and on a circle

Two points are randomly selected on the circle. What is the expected distance between them? And what will be the expected distance between the two points on a sphere?

An interesting problem, I had several ideas: we can generate a uniform distribution in an $$n$$-dimensional cube described around a unit ball, remove points outside the ball from the sample, and obtain a uniform distribution of vectors in the ball. We normalize the vectors - we get on the sphere. And we use Monte Carlo.... Of course, there are a lot of iterations, and the accuracy is low, but for a rough estimate and for checking the exact calculations, it will do well.

I also reasoned like this: since the task does not change when rotating, I can take one point fixed. We get the expectation of the distance from a random point of the circle to a fixed one. This is an obvious integral:

$$\frac{1}{2 \pi} \int_{-\pi}^{\pi} \sqrt{(1-\cos x)^{2}+\sin ^{2} x}\,dx=\frac{1}{\pi} \int_{-\pi}^{\pi}\left|\sin \frac{x}{2}\right|dx=\frac{2}{\pi} \int_{0}^{\pi} \sin \frac{x}{2}\,dx=\frac{4}{\pi}$$ - for the unit circle, of course.

\begin{aligned} &\frac{1}{4 \pi} \int_{0}^{\pi} \int_{-\pi}^{\pi} \sin \theta \sqrt{(1-\cos \theta)^{2}+\sin ^{2} \theta \cos ^{2} \varphi+\sin ^{2} \theta \sin ^{2} \varphi}\, d \varphi d \theta= \\ &=\frac{1}{2} \int_{0}^{\pi} 2 \sin \frac{\theta}{2} \sin \theta\, d \theta=\frac{1}{2} \int_{0}^{\pi} \cos \frac{\theta}{2}-\cos \frac{3 \theta}{2} d \theta=\left.\left(\sin \frac{\theta}{2}-\frac{1}{3} \sin \frac{3 \theta}{2}\right)\right|_{0} ^{\pi}=\frac{4}{3} \end{aligned}. -and this is for the sphere.

Parameterization of the sphere: $$z=\cos(\theta)$$, $$x=\sin(\theta)\cos(φ)$$, $$y=\sin(\theta)\sin(φ)$$. As a fixed point we take $$(0,0,1)$$. Jacobian $$\sin(\theta)$$. I took a slightly non-standard parameterization relative to theta, so that later I would not mess with things like $$\sin (\pi/4-\theta/2)$$.

Here are my thoughts. I ask you to double-check me and, if possible, write your own version.

• Yes it seems all correct to me. Jul 28, 2021 at 13:49
• Coincidently I just solved the circle case for you on Quora. I cannot find mistakes in your handling of the sphere. Jul 28, 2021 at 13:51
• @drhab You mean this question: quora.com/… Jul 28, 2021 at 13:53
• Your link does not work properly but I am sure it is your question there. Jul 28, 2021 at 13:54
• @drhab Also, here is the formula for n-dimensional space $$M[d]=\frac{2 \int_{0}^{\pi} \sin ^{n-2} \theta \sin \frac{\theta}{2} d \theta}{\int_{0}^{\pi} \sin ^{n-2} \theta d \theta}$$ For 4-dimensional we get $64/(15\pi)$ Jul 28, 2021 at 14:03

I do not have a lot of time now, so let me look at the circle case only. The assumption of one fixed point was a wise shortcut. I might exploit the symmetry to suggest another here. Let $$\theta$$ be the central angle subtended by the two points. It is only necessary to integrate from 0 to $$\pi$$. Let $$r$$ be the circle radius.

$$\frac{2r}{\pi} \int_{0}^{\pi} \sin \frac{\theta}{2} d\theta = \frac{4r}{\pi}$$

Edit:

Having more time now, I might look at the sphere. I am not exactly following your integral, but we are reaching the same bottom line, so that looks good. Before starting the sphere, I want to come clean on my circle. There was a typo in the integral, but remarkably it led to the same result. I have since corrected it.

Let $$\varphi$$ be the angle subtended by the fixed point and the variable point on the sphere. Again use radius $$r$$. The locus of the variable points defining that angle is a circle with radius $$r\sin \varphi$$, so its circumference is $$2\pi r\sin \varphi$$. Let it mark a strip of width $$rd\varphi$$, giving it area $$2\pi r^2 \sin \varphi d\varphi$$. The probability of the point falling on that strip is that area divided by the total surface area of the sphere.

probability = $$\frac{2\pi r^2 \sin \varphi d\varphi}{4\pi r^2} = \frac{1}{2} \sin \varphi d\varphi$$

length of chord = $$2r\sin \frac{\varphi}{2}$$

expectation = $$r \int_{0}^{\pi} \sin \varphi \sin \frac{\varphi}{2} d\varphi$$

= $$2r \int_{0}^{\pi} \sin^2 \frac{\varphi}{2}\cos \frac{\varphi}{2} d\varphi$$

= $$\frac{4r}{3} [\sin^3 \frac{\varphi}{2}]_{0}^{\pi}$$

= $$\frac {4r}{3}$$

I tend to use geometry as far as it will carry me. In this case, that served to simplify both integrals. Not everyone responds to that. See what you think.

• Please, use \sin and \cos. Jul 29, 2021 at 0:02
• Oh, I see. That identifies them as functions, and they are no longer in italics. Thank you.
– Pope
Jul 29, 2021 at 7:23
• No no no. Generating points uniformly on a cube then projecting them onto a sphere does not give a uniform distribution on the sphere. Points will be denser in the directions of the corners of the sphere. There are several published algorithms for generating points randomly and uniformly on an $n$-dimensional sphere, and these are built into many software systems such as Mathematica's SpherePoints[]. Jul 29, 2021 at 8:02