From: Caleb Clausen Date: 2010-06-23T10:56:15+09:00 Subject: Re: [QUIZ] Random Points within a Circle (#234) On 6/22/10, Colin Bartlett wrote: > The random angle bit in your method is OK. > For the square root: the area of an annulus radius r to r+e is > pi * ( (r+e)**2 - r**2 ) = pi * 2*r*e + pi * e**2 > So, if I treat e as an infinitesimal and neglect the e**2 (and hope that no > real mathematicians are looking, or claim I'm using > Abraham Robinson's http://en.wikipedia.org/wiki/Abraham_robinson > Non-Standard Analysis http://en.wikipedia.org/wiki/Non-standard_analysis > and hope that nobody asks me any awkward questions about how that really > works) > the area of the annulus is (approximately) pi * 2*r*e. > (Think of it as a (very) "bent" rectangle of length pi * 2*r with a "width" > of e.) > > If you use a uniform distribution for the radius to the random point then on > average you'll be putting the same number of points in an annulus (a0) of > width e very close to the centre of the circle as in an annulus (a1) of > width e very close to the circumference of the circle. But the annulus (a1) > has a much larger area than the annulus (a0), so the density of points will > be greater in annulus (a0) than annulus (a1). Which is why Dave Howell made > his comment. That was beautiful! The best explanation yet. Thank you. I keep wondering the use of sqrt will cause weird float rounding errors; that is will there be valid [float, float] pairs which are in the circle but can never be be found by an algorithm that includes Math.sqrt(rand)? Maybe someone with a better grip on the math has an answer to this.