# Mean distance between a fixed point and a uniform distributed random variable

In a square with dimension $M$ I have a fixed point $A$ with $(x_a,y_a)$ coordinates and some other random nodes $B_1,B_2,\dots,B_n$ with random uniformly distributed coordinates. I want to find out the mean distance between a fixed point and a uniformly distributed random variable.

-

It seems one does not need to introduce more than one uniformly distributed random point $B$ and that you look for $m(A)=E(\text{dist}(A,B))$. Assuming without loss of generality that the square has side $1$, $$m(x_a,y_a)=\int_0^1\int_0^1\sqrt{(x-x_a)^2+(y-y_a)^2}\mathrm{d}x\mathrm{d}y.$$ One can write down several equivalent formulas for $m(x_a,y_a)$, none of them very enlightening, and I doubt that a general expression exists, involving only usual functions.

Nevertheless, obvious symmetries of the problem yield that $m$ is invariant under the action of the transformations $(x_a,y_a)\mapsto(y_a,x_a)$, $(x_a,y_a)\mapsto(1-x_a,y_a)$ and $(x_a,y_a)\mapsto(x_a,1-y_a)$. And the function $m$ is maximal at the four corners and minimal at the center of the square.

One can compute the value of $m$ at these points. For example, using polar coordinates $(r,\theta)$, $$m(0,0)=2\int_0^{\pi/4}\int_0^{1/\cos\theta}r^2\mathrm{d}r\mathrm{d}\theta=\frac23\int_0^{\pi/4}\frac{\mathrm{d}\theta}{\cos^3\theta}=\frac23\int_0^{\sqrt2/2}\frac{\mathrm{d}s}{(1-s^2)^2},$$ which should yield something like $m(0,0)=\frac13(\sqrt2+\log(1+\sqrt2))=0.765195716.$

And if $A$ is the center of the square, $m(A)$ is also the mean distance between $A$ and a random point $B'$ uniformly distributed in the square $\frac12\le x,y\le1$. The point $A$ and this smaller square are homothetic to the point $(0,0)$ and the original square, with ratio $\frac12$, hence $m(\frac12,\frac12)=\frac12m(0,0).$

-
The distance of $(x_a, y_a)$ to $B_i=(x_i,y_i)$ is $d_i=\sqrt{ (x_a-x_i)^2+(y_a-y_i)^2 }$
You want to find $(1/n) \sum_i \mathrm E [d_i]$