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

Home > Probability
Three Points in a Square (Posted on 2008-03-17) Difficulty: 3 of 5
Three points are chosen at random inside a square. Each point is chosen by choosing a random x-coordinate and a random y-coordinate.

A triangle is drawn with the three random points as the vertices. What is the probability that the center of the square is inside the triangle?

No Solution Yet Submitted by Brian Smith    
Rating: 4.0000 (5 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
re(4): Not faster, simpler, or better | Comment 13 of 18 |
(In reply to re(3): Not faster, simpler, or better by ed bottemiller)

As an example of a point other than the center to be tested for inclusion in the triangle, take a point that's midway between the center and one of the corners of the square, at (0.75,0.75) (for a square with diagonal from (0,0) to (1,1).

In 1,000,000 trials, 92,807 of the time this point was within the triangle, for a probability of 0.092807. To allow for the vagaries of the simulation, say 0.0928 or 0.093. That's quite a bit smaller than 1/4. It's between 1/10  and 1/11.

DEFDBL A-Z

FOR i = 1 TO 1000000
   x1 = RND(1): y1 = RND(1)
   x2 = RND(1): y2 = RND(1)
   x3 = RND(1): y3 = RND(1)

   m = (y2 - y1) / (x2 - x1)
   a = y1 - m * x1
   test1 = y3 - (m * x3 + a)
   test2 = .75 - (m * .75 + a)

   m = (y3 - y1) / (x3 - x1)
   a = y1 - m * x1
   test3 = y2 - (m * x2 + a)
   test4 = .75 - (m * .75 + a)

   m = (y3 - y2) / (x3 - x2)
   a = y2 - m * x2
   test5 = y1 - (m * x1 + a)
   test6 = .75 - (m * .75 + a)

   IF test1 * test2 > 0 AND test3 * test4 > 0 AND test5 * test6 > 0 THEN
     hit = hit + 1
   END IF
   ct = ct + 1
   PRINT hit, ct, hit / ct
NEXT

 


  Posted by Charlie on 2008-03-18 16:49:16
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 (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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