I was wondering what was the average distance "d" of any point in a ball to its boundary (not specifically the closest point). I made a simple monte carlo computation using Muller's method to get a uniform distribution - see linked answer : Python Uniform distribution of points on 4 dimensional sphere : def sample_within(radius, dim, nb_points=1, ): # Gaussian-distributed points x = np.random.normal(size=(nb_points, dim)) # Normalize to unit length (points on the surface of the n-sphere) x /= np.linalg.norm(x, axis=1)[:, np.newaxis] # Random radii with distribution ~ r^(1/n) => uniform volumic distribution in the ball r = np.random.rand(nb_points) ** (1/dim) # Scale by radius points = radius * x * r[:, np.newaxis] return points Note: I also used a "stupid" sampling in a box and discarding what ever points lies out of the sphere, everything I say in this post is true wiht both sampling method as they produce the same outcome. And using (the same method) : def sample_on_border(radius, dim:int, nb_points:int): # Gaussian-distributed points x = np.random.normal(size=(nb_points, dim)) # Normalize to unit length (points on the surface of the dim-sphere) x /= np.linalg.norm(x, axis=1)[:, np.newaxis] # Scale by radius points = radius * x return points The distances are calculated using (which I have checked manually): def calc_average_distance(radius: float, dim: int, nb_in_points: int, nb_border_points: int)->float: border_points = sample_on_border(radius, dim, nb_border_points) in_points = sample_within(radius, dim, nb_in_points) # in_points = border_points #specific case R=1 distances = np.sqrt(np.sum((border_points[:, np.newaxis, :] - in_points[np.newaxis, :, :])**2, axis=2)) average_distance_to_border = np.mean(distances) return average_distance_to_border From now on, I will speak in dimension 2 (disk) and with a radius of 1. Note: It is easy to demonstrate that the average distance between 2 points of the circle is 4/pi (1.27), and using only sampled points on the border in my Monte Carlo computation yield the same result. Also, the average distance between the center of the circle and the points of the circle is obviously 1 (since R=1). Therefore, I would expect the average distance d to be between 1 and 1.27 (it is just intuition though). The computed average distance d is : d = 1.13182 ± 0.00035 (with 5 sigma confidence) which is indeed between 1 and 1.27 (seems to even be the average). Now, I was also interest to find if there is an analytical solution to this problem, and I found the paper "The Average Directional Distance To The Boundary Of A Ball Or Disk" at https://www.emis.de/journals/AMEN/2024/AMEN-A230614.pdf This paper adress the problem in n-dimension, but its first section specifically deal with the case in dimension 2. Note: For the average distance between two points on the unit circle (i.e., when R=1), the paper gives the result 2/pi . However, unless I am mistaken, the correct value should be 4/π as previously stated and this can even be derived from the paper formula by taking r=R=1. However, I cannot find any (other) mistake in the paper and the analytical solution (which I have checked several times) yields 8/3pi so around 0.85 which is obvisouly different from the 1.13 I get when using my monte carlo code (and also not between 1 and 4/pi). Also, just to be sure, I tried: sampling non-uniformly (using uniform distribution to sample radius instead of using normal distribution), and I get another answer (1.088) but still not 0.85. or by sampling only along the segment [0, 1] (exploiting the problem symmetries) which gives 1.13 again or 1.088 again (depending if uniformly distributed or not). Using polar coordinates in 2D, also gives 1.13. Can anyone help me identify a mistake in my reasoning/code ? Edit: I failed to mention, that this post https://math.stackexchange.com/ques...-a-point-in-a-ball-to-a-point-on-its-boundary gives 6/5 for a 3d-ball which is the result I get by Monte-Carlo but differs from the paper's result (3/4). Thanks Continue reading...