Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Random numbers Perl ok! (I think)

by demerphq (Chancellor)
on Oct 12, 2003 at 11:08 UTC ( #298631=note: print w/ replies, xml ) Need Help??


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



Comment on Re: Random numbers Perl ok! (I think)
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://298631]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2015-07-05 19:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls