Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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


Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://298631]
help
Chatterbox?
[choroba]: Low-end is defined as the Perl that generates millions of income
[choroba]: sorry, that's high-end, of coursse
[choroba]: low end, in my talk, will be code that "we don't touch because it works" and noone knows why
[choroba]: I want to present the most bizzare bugs and misfeatures I met when working for a large financial institution
[choroba]: I already gave a similar talk to my friends in a pub and at an internal conference at work and people liked it, so maybe...
[choroba]: LanX: That's the heritage, I can't do anything else
[RonW]: Sounds like some system my employer has "It does exactly what we need it to do and can't afford to risk anything we can't prove is 100% compatible"
[marto]: choroba sounds interesting
[RonW]: james28909 Why not write a Perl program to do the task?
[choroba]: RonW Yes, but then, one day, they needed to switch from FTP to SFTP, and... but I can't give the whole talk away here :)

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2017-05-22 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?