![]() |
|
Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Efficient ways of storing a data set for random accessby Roy Johnson (Monsignor) |
on Jan 29, 2004 at 16:19 UTC ( #324948=note: print w/replies, xml ) | Need Help?? |
A sum of random numbers will be more bell-shaped than a single random number. Hence, rolling 2 6-sided dice will yield more sevens on average than rolling an 11-sided die numbered from 2 to 12. The more dice, the more heavily weighted toward the center of the range you'll be.
For your 6-21 example, there are 16 numbers that need to be covered. You could roll two 16-sided dice, add them together, and divide by two to get a center-weighted result in the desired range. Here's a little program to demonstrate the distribution:
The PerlMonk tr/// Advocate
In Section
Seekers of Perl Wisdom
|
|