note
Roy Johnson
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.
<P>
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.
<P>
Here's a little program to demonstrate the distribution:
<code>
my $range=16;
my $low_end=6;
my %freq = ();
for (1..1000) {
my $result = int((rand($range)+rand($range))/2)+$low_end;
++$freq{$result};
}
print "$_: $freq{$_}\n" for (sort {$a<=>$b} keys %freq);
__END__
6: 10
7: 35
8: 44
9: 52
10: 61
11: 77
12: 107
13: 109
14: 118
15: 111
16: 95
17: 46
18: 49
19: 57
20: 24
21: 5
</code>
<div class="pmsig">
<div class="pmsig-300037">
<hr>
<small>The PerlMonk <tt>tr///</tt> Advocate</small>
</div></div>
324866
324866