
Re: Random Triangle Problem
Posted:
Aug 4, 1997 8:31 AM


In article <33E254FD.7B33@virginia.edu>, "Charles H. Giffen" <chg4k@virginia.edu> writes: > Bill Taylor wrote: > > > > eclrh@sun.leeds.ac.uk (Robert Hill) writes of some fascinating simulation data! > > > > > I generated 1 million pseudorandom triangles > > > > > (1) vertices independent uniform inside a square: > > > obtuse at first vertex at second at third all acute > > > 241781 241998 241802 274419 > > > > > > (2) vertices independent uniform inside a circle: > > > 248534 248198 248619 254649 > > > > > > (3) vertices independent uniform inside an equilateral triangle: > > > 249377 249031 249279 252313 > > > > These are all *hugely* away from 3/4 to 1/4. The best has a chisquare > > of about 20 for 1 df. MADLY significant. > > > > [snip] > > Hm! Out of 10 million triangles, I got > > 7483180 obtuse inside an equilateral triangle > 7250536 obtuse inside a square > 7196418 obtuse inside a circle > 9079940 obtuse inside a rectangle (1 x 4, I believe). > > (vertices independent inside the region in question). > > How good is your random number generator (mine generates random > 32 bit integers and then rescales  and the algorithm is one > recommended by Knoth).
Don't blame the subtleties of my random number generator (NAG Fortran Library G05CAF with 64bit IEEE reals on Sun and SGI machines), blame my gross programming mistake!
Your figures for a square and an equilateral triangle seem reasonably close to mine. If I remember rightly we should expect differences of a few times sigma = sqrt(npq) = about 430 on samples of 1 million.
My program for a circle contained a stupid error. I was trying to generate uniform points in a square and reject those outside the inscribed unit circle, but I forgot to first transform from the square [0,1]x[0,1] to [1,1]x[1,1], so those figures are actually for a quadrant. Correcting the bug, I get 720578 obtuse out of a million, or 7200949 out of 10 million, reasonably close both to your figures and to the theoretical .7187 that has now been posted by Keith Ramsay.
This makes the results for a square intermediate between those for a triangle and those for a circle, destroying of a surprising observation I made.  Robert Hill
University Computing Service, Leeds University, England
"Though all my wares be trash, the heart is true."  John Dowland, Fine Knacks for Ladies (1600)

