Results:#!/usr/bin/perl use strict; use warnings; use 5.014; my %rand; for (1 .. 2**25) { my $r = rand; $rand{ $r }++; } say scalar keys %rand; use Math::Random::MT::Auto qw(rand); %rand = (); for (1 .. 2**25) { my $r = rand; $rand{ $r }++; } say scalar keys %rand;
You can see that for 2**25 == 33_554_432 the built in rand only produced 2**15 == 32768 random numbers but the module produced an entire range of random numbers equal to 2**25.C:\Old_Data\perlp>perl t.pl 32768 33554432 C:\Old_Data\perlp>perl -E "say 2**25" 33554432 C:\Old_Data\perlp>perl -E "say 2**15" 32768 C:\Old_Data\perlp>
Update: perl version -
C:\Old_Data\perlp>perl -v
This is perl 5, version 14, subversion 1 (v5.14.1) built for MSWin32-x64-multi-thread
Windows version - 7
In reply to Re: Perl rand() generates larger numbers for small sample size, bug!
by Cristoforo
in thread Perl rand() generates larger numbers for small sample size, bug!
by ravipatel4
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |