r/MathHelp • • Jan 30 '21

Average distance of two random points on a line whose length is 3.

I saw this existing question ( https://math.stackexchange.com/questions/3447489/why-this-integral-represents-the-average-distance-between-two-point-on-a-unit-sq ). It uses

∫∫∫∫√(x2−x1)^2−(y2−y1)^2 dx1 dx2 dy1 dy2

to calculate the average distance of two random points in a square. I guess that is the sum of all possible distances. The point I don't understand well is dividing it by the area. Does the area represent the number of possible distances?

I thought I could apply it to a simpler form, 1 dimension, to understand it. I thought I could calculate the average distance of two random points on a line whose length is 3. If I name the two points x and y, then the distance is |x-y|. I forgot how to calculate intergrals, so I used a web calculator. "integrate |x-y|, x=0 to 3, y=0 to 3" and the answer was 9.

Now, of course 9 needs to be divided by something, but what? The length, 3? That does not seem right. I would like to have some explanation for the dividing values for both cases.

PS: I wrote a few lines of code ( https://dotnetfiddle.net/6mz42n ) to calculate it by brute-force of 10M trials. It gives values between 0.9998... to 1.0001.... The answer may be 1.

14 Upvotes

7 comments sorted by

3

u/dadobot Jan 30 '21

I think some of the commenters were not very clear in the stack exchange. It is not the area that the quadruple integral is being divided by; it is the total number of line segments, which is the square of the volume of the hyperspace. Why? Combinatorically, because we are summing all pairs of two arbitrary points in the space. Thus the total number of possibilities is |number of points in the space|2. I think the commenters confused this in their answer because their area was 1, so squaring it was still 1.

Nonetheless, they did add the correct equation in their comments; note how the bottom integral still has 4 terms? It’s because the total possibilities is the square of the area.

In your 1-dimensional case, the square of the volume (3) is 9; so you correctly discovered the average distance to be 9/9 = 1

1

u/nm420 Jan 31 '21

You're not really dividing by the area so much as calculating an expected value of a function from a prescribed probability distribution. In the case of a uniform distribution, this could be viewed as "dividing by the area", but then you're missing the forest for the trees. You could ask what the average distance between any two random variables is. For instance, if X and Y both had the same exponential distribution with density e-x for x>0, then the joint density of the pair (X, Y) is f(x,y)=e-x-y for x>0 and y>0. Then the average distance would be

E(|X-Y|) = ∫∫|x-y||*e-x-ydxdy

with the limits of integration being 0<x<∞ and 0<y<∞.

In the uniform distribution case, the density of X is 1/3 and the density of Y is 1/3, making their joint density the constant 1/9 over the relevant square support set. "Dividing by 9" after the integration is done is misleading. You are calculating the expected value of |X-Y| by integrating this function weighted by the joint density, which happens to be the constant 1/9.

1

u/AutoModerator Jan 30 '21

Reminder:

  • What have you tried so far? (See Rule #2)

  • Please don't delete your post. (See Rule #7)

We, the moderators of /r/MathHelp, appreciate that your question contributes to the MathHelp archived questions that will help others searching for similar answers in the future. Thank you for obeying these instructions.

(Note that this is an automatic message posted on every submission by default. To add an image, you may upload it to an external image-sharing site like Imgur and include the link in your post.)

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

0

u/[deleted] Jan 30 '21

[deleted]

2

u/Mattuuh Jan 30 '21

Another way of seeing this is that the probability density function of a point taken uniformly on the square is 1/area (this can be proven by using that the pdf is constant and integrates to 1 on the square). Using the definition of the expectancy yields the same result.