On Jun 21, 2010, at 15:45 , Caleb Clausen wrote:

> On 6/19/10, Daniel Moore <yahivin / gmail.com> wrote:
>> The quiz this week
>> is to generate random points uniformly distributed within a circle of
>> a given radius and position.
> 
> def random_point_in_a_circle(x,y,r)
>  angle=rand*2*Math::PI
>  r*=rand
>  x+=r*Math.sin(angle)
>  y+=r*Math.cos(angle)
> 
>  return x,y
> end
> 
> 7 lines, 5 minutes, 0 tests or visualizations. Super-easy.

And wrong, unfortunately. You're selecting a random angle, and then a random distance from the center. This will result in way too many points at the center of the circle.