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

Home > Shapes
Mean Distance Two Points (Posted on 2013-06-01) Difficulty: 3 of 5
[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.)
Some Thoughts Numerically | Comment 1 of 8

Part 1:

DEFDBL A-Z
RANDOMIZE TIMER
FOR tr = 1 TO 1000000
 p1 = RND(1) * 4
 p2 = RND(1) * 4
 SELECT CASE p1
   CASE IS < 1
    y1 = 0: x1 = p1
   CASE 1 TO 2
    x1 = 1: y1 = p1 - 1
   CASE 2 TO 3
    y1 = 1: x1 = 1 - (p1 - 2)
   CASE IS > 3
    x1 = 0: y1 = 1 - (p1 - 3)
 END SELECT
 SELECT CASE p2
   CASE IS < 1
    y2 = 0: x2 = p2
   CASE 1 TO 2
    x2 = 1: y2 = p2 - 1
   CASE 2 TO 3
    y2 = 1: x2 = 1 - (p2 - 2)
   CASE IS > 3
    x2 = 0: y2 = 1 - (p2 - 3)
 END SELECT
 dist = SQR((x1 - x2) ^ 2 + (y1 - y2) ^ 2)
 tdist = tdist + dist
 PRINT tdist / tr
NEXT

finds an average of about 0.735 or 0.736.

Part 2:

DEFDBL A-Z
RANDOMIZE TIMER
FOR tr = 1 TO 1000000
 x1 = RND(1): y1 = RND(1)
 x2 = RND(1): y2 = RND(1)
 dist = SQR((x1 - x2) ^ 2 + (y1 - y2) ^ 2)
 tdist = tdist + dist
 PRINT tdist / tr
NEXT

finds an average of about 0.521 or 0.522


  Posted by Charlie on 2013-06-01 11:36:38
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (5)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information