# Probability distribution or the distance between two points in $n$-dimensional Euclidean space after a random perturbation of one point

Take two points, $p_0$ and $p_k$, in $n$-dimensional Euclidean space, where $d(p_0,p_k)$ is the distance between the points. Now, draw an $n$-sphere of radius $r$ centered on $p_0$ and uniformly select a new point, $p_1$, in the volume of the sphere, and a new point $p_2$ on the surface of the sphere.

Let $h_1 = d(p_0,p_k) - d(p_1,p_k)$, and $h_2 = d(p_0,p_k) - d(p_2,p_k)$, represent the difference in the distance from $p_0$ to $p_k$ if $p_0$ is moved to $p_1$ or $p_2$, respectively. To clarify, if we blow up another $n$-sphere, $S$, about $p_k$ until $p_0$ "touches" its contour, $h_1$ / $h_2$ will be positive if $p_1$ / $p_2$ is inside $S$, zero if $p_1$ / $p_2$ are on the contour of $S$, and negative if $p_1$ / $p_2$ fall outside $S$.

What probability distribution and expectation do we have for $h_1$ and $h_2$?

Update [2/15/2014] :: Thanks to Bjørn Kjos-Hanssen's efforts, we have a nice exact expression for the $n = 2$ case for $h_1$ (which implies that we have expectation --- $\int_{1-r}^{1+r} \space R \times f(R) \space dR$). At this point, I think its probably wise to restrict the focus or scope of this question to the $n = 2$ case. Can a PDF for $h_2$ (where we select points along the contour of the circle) be derived in a similar manner?

-

Let us consider the case $n=2$. Assume $p_k$ is at the origin and $p_0$ is at the point $(1,0)$ on the $x$-axis, and that $r<1$.

## Distribution of $h_1$

By subtracting a constant it suffices to find the distribution of $d:=d(p_1,0)$.

The density for $d$, $f_d(R)$, is proportional to $R\Theta$ where $\Theta$ is length of the interval of angles $\theta$ for which the point $(R\cos\theta,R\sin\theta)$ is within $r$ of $(1,0)$. Now, calculation shows that $$|(R\cos\theta,R\sin\theta)-(1,0)| < r$$ is equivalent to $$|\theta| < \arccos\left(\frac{R^2+1-r^2}{2R}\right)$$ so $f_d(R)$ is proportional to $$2R\arccos\left(\frac{R^2+1-r^2}{2R}\right),\quad R\in [1-r,1+r].$$ and $f_d(R)=0$ for $R\not\in [1-r,1+r]$.

For geometric reasons (and one could also check it analytically) the integral of the given expression over the given interval is $\pi r^2$. So

$$f(R)=\frac{2R\arccos\left(\frac{R^2+1-r^2}{2R}\right)}{\pi r^2},\quad 1-r\le R\le 1+r.$$

## Distribution of $h_2$

The squared distance from $(1,0)+r(\cos\theta,\sin\theta)$ to the origin is $$D^2 : = (r\cos\theta+1)^2+(r\sin\theta)^2 = r^2 + 1 + 2r\cos\theta$$ and the probability of picking a point $R$ or more away from the origin is then $1/\pi$ times $\theta_R>0$ where $\theta=\theta_R$ makes $D^2=R^2$. Namely $$\theta_R = \arccos\left(\frac{R^2-r^2-1}{2r}\right)$$ Then the density is

$$f(R)= \frac{-1}{\pi} \frac{d}{dR} \arccos\left(\frac{R^2-r^2-1}{2r}\right);$$

$$f(R)=\frac1{\pi}\frac{1}{\sqrt{1-u(R)^2}} \frac{R}{r},\quad 1-r\le R\le 1+r,$$ where $u(R)=\frac{R^2-r^2-1}{2r}$.

-
Thanks for the update! –  Sauer Feb 15 at 8:01
Apologies, my previous comments regarding an imaginary component in the expectation, while unresolved, must be a problem with Maple. I do not see an issue with the derivation of the PDF for $h_2$. –  Sauer Feb 16 at 16:57
Try $r = 0.1$. In both Maple and Mathematica, I see an imaginary component. Since I have Mathematica up at the moment, I find an expectation of: $1.0025 - 3.1372*10^{-11} i$ for $r = 0.1$. The magnitude of the imaginary component appears to increase with additional working precision. –  Sauer Feb 16 at 17:08
Well, I see an increase in the magnitude of the imaginary component with increasing working precision. This tells me that it's likely a bug or some problem with rounding. –  Sauer Feb 16 at 17:11
The imaginary component should be zero, right? I'm a little confused because you said "maybe zero" in a previous comment? –  Sauer Feb 16 at 17:13