http://www.perlmonks.org?node_id=298631


in reply to Random numbers Perl ok! (I think)

Hmm. I looked into this (god knows why, im not a math type at all, nor do I use random numbers for anything serious). My code is as follows:

my $count=1; my %hash; my $last=-1; for (1..1000000) { my $num=int rand 10; if ($num == $last) { $count++; } else { $hash{$last}{$count}++ unless $last<0; $count=1; } $last=$num; } use Data::BFDump; Dump(\%hash)->Out();

Ive run it a few times for various large number of iterations and it does seem like sequences of 0 are just slightly more common than other numbers. I dont have the stats skills currently and I can't be bothered doing the research to find out how to find out how much the deviation is, or if its signifigant. Update: Nah. I did a few more runs, I now dont think there appears to be much difference.

Im hoping tilly or one of the other math types comes in and explains all this for us. :-)

$HASH1 = { 0 => { 1 => 809217, 2 => 80661, 3 => 8105, 4 => 793, 5 => 78, 6 => 14 }, 1 => { 1 => 809964, 2 => 81041, 3 => 7980, 4 => 824, 5 => 90, 6 => 7, 7 => 1 }, 2 => { 1 => 809678, 2 => 81151, 3 => 8134, 4 => 837, 5 => 74, 6 => 4, 7 => 2 }, 3 => { 1 => 810420, 2 => 80495, 3 => 8204, 4 => 809, 5 => 96, 6 => 4, 7 => 2 }, 4 => { 1 => 809280, 2 => 81142, 3 => 8068, 4 => 795, 5 => 72, 6 => 12, 7 => 1 }, 5 => { 1 => 808510, 2 => 81230, 3 => 8157, 4 => 841, 5 => 83, 6 => 9, 7 => 1 }, 6 => { 1 => 811176, 2 => 81502, 3 => 8166, 4 => 817, 5 => 68, 6 => 9 }, 7 => { 1 => 810293, 2 => 80902, 3 => 8071, 4 => 788, 5 => 78, 6 => 11, 7 => 1 }, 8 => { 1 => 809579, 2 => 81208, 3 => 8061, 4 => 837, 5 => 81, 6 => 9, 7 => 1 }, 9 => { 1 => 809785, 2 => 81492, 3 => 8071, 4 => 857, 5 => 83, 6 => 9 } };


---
demerphq

    First they ignore you, then they laugh at you, then they fight you, then you win.
    -- Gandhi