The stupid question is the question not asked | |
PerlMonks |
Re: Monte Carlo approximation of PIby robartes (Priest) |
on Apr 04, 2003 at 11:40 UTC ( [id://248032]=note: print w/replies, xml ) | Need Help?? |
Very nice, but shouldn't it be rand()**2 + rand()**2 <= 1? Given the fact that the range of numbers returned from a random generator is discrete, given enough iterations, doing just < 1 would underestimate pi ever so slightly. Then again, nobody would probably run this algorithm long enough to see an effect from this :).
CU
In Section
Cool Uses for Perl
|
|