in reply to Re: max random
in thread max random
You have to be careful with this. If you require random integers in a range greater than the number of random bits provided by your Perl installation, and get them using the usual multiply and int idiom, you won't get the results you want.
Eg. using the 15-bit rand() available from AS Perl to produce integers in the range 0 .. 100,000:
$x{ int( rand 100000 ) }++ for 1 .. 1000000;; print "$_ => $x{ $_ }" for sort{ $a <=> $b } keys %x;; 0 => 45 3 => 30 6 => 31 9 => 32 12 => 30 15 => 27 18 => 24 21 => 20 24 => 22 27 => 23 30 => 36 ...
|
|---|