Assuming the square had 100 pixels per side, on the average, approximately how 
many random pixels should be plotted in the square before obtaining a 
reasonably good estimate of pi?

Benjamin L. Russell

--- On Mon, 4/28/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> From: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> Subject: Re: [Haskell-cafe] approximating pi
> To: [email protected]
> Date: Monday, April 28, 2008, 9:54 AM
> Don Stewart writes: 
> 
> > Ry Dahl:
> >> By picking points randomly from a square one can
> calculate pi.
> ...
> >> What is the best way to express this algorithm in
> Haskell?
> > 
> > Using a random generator, such as System.Random or
> > System.Random.Mersenne, generate random numbers in
> your range,
> > testing if they're inside the circle, and loop
> until your limit
> > condition is reached. 
> > 
> > The full program is about 10 lines or so, so
> shouldn't be too hard to
> > work out, once you've worked out how to generate
> Doubles from
> > System.Random.random
> 
> Ry Dahl seems to know Ruby. Ruby has also comprehensions.
> So, why not use
> 'randoms' to generate an infinite list of them,
> 'take' some N, and then
> 'sum' 1 on randoms filtered by the circle
> condition. I think that you
> won't need full 10 lines of code... 
> 
> Jerzy Karczmarczuk 
> 
> 
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to