All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Mean Distance Two Points (Posted on 2013-06-01)
[1] What is the mean distance between two random points on the perimeter of a unit square?

[2] What is the mean distance between two random points on the interior of a unit square?

 No Solution Yet Submitted by Danish Ahmed Khan No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 re: Part 2 in two different ways. | Comment 4 of 8 |
(In reply to Part 2 in two different ways. by Jer)

The following program does the numerical integration for n = 2 to 20:

DEFDBL A-Z
RANDOMIZE TIMER
CLS
FOR n = 2 TO 20
tdist = 0: numdist = 0
st = 1 / (2 * n): incr = 1 / n
FOR x1 = st TO 1 STEP incr
FOR x2 = st TO 1 STEP incr
FOR y1 = st TO 1 STEP incr
FOR y2 = st TO 1 STEP incr
dist = SQR((x1 - x2) ^ 2 + (y1 - y2) ^ 2)
tdist = tdist + dist
numdist = numdist + 1
NEXT
NEXT
NEXT
NEXT
PRINT n, numdist, tdist / numdist
NEXT

The results for n=2 and n=3 agree with Jer's, but not for n=4:

`n             number of      mean distance              distances2             16            .42677669529663693             81            .48443709109856384             256           .50200374234502235             625           .50951299607276996             1296          .51338616937732057             2401          .51563792025363928             4096          .5170603389256799             6561          .518015364345619210            10000         .518687222121322611            14641         .519177635313031612            20736         .519546466568149813            28561         .519830797045825414            38416         .520054585231113615            50625         .520233867062498316            65536         .52037970253233317            83521         .520499919124534418            104976        .520600182299784919            130321        .520684674232451620            160000        .5207565364233291`

I think it makes sense that the distance is continually increasing as it gets to include larger and larger almost-full diagonal lengths.

 Posted by Charlie on 2013-06-02 10:43:12

 Search: Search body:
Forums (0)