Perl-Sensitive Sunglasses | |
PerlMonks |
Lots of rand()sby David Caughell (Monk) |
on Mar 08, 2004 at 11:59 UTC ( [id://334772]=CUFP: print w/replies, xml ) | Need Help?? |
Some of the coolest programs are the ones with random results... russian roullette, initial placement in Life, etc. I wanted to see how close to even rand() would get over a large sample size, so I ran 100 million tests, and published the results. If this gets moved to Code Catacombs, that's fine by me. It's not exactly cool, but it is cool by extension. :) Also, if someone would like to comment on how it could be made more efficient, that would be awesome! I'm specifically interested in the while block, because it's the workhorse, though other comments are good too. Code:
Output: Total 100000000 1: 10003440 10.00344 2: 9996091 9.996091 3: 10004370 10.00437 4: 9996926 9.996926 5: 10000607 10.000607 6: 9998471 9.998471 7: 10002412 10.002412 8: 9997738 9.997738 9: 9999782 9.999782 10: 10000163 10.000163
Back to
Cool Uses for Perl
|
|