carlos fandango has asked for the wisdom of the Perl Monks concerning the following question:
My question: why aren't the values correct? You'd expect 100 errors at a 1 in 10000 error rate, not the 84 (average) above. At a 1 in 100000 rate you'd expect 10, not 0. What's going on here - I'm going crazy. This should be so simple ...for ($x=10; $x<1000000; $x=$x*10){ $error_rate = $x; print "Error rate = 1 every $x, errors = "; for ($y=0;$y<5;$y++){ errortest(); } print "\n"; } sub errortest { $errors = 0; for ($n=0;$n<1000000;$n++){ $random = int (rand($error_rate)); if ($random == 1){$errors++} } print $errors, " "; } Output: Error rate = 1 every 10, errors = 99778 100371 99586 99912 99778 Error rate = 1 every 100, errors = 10007 9962 9803 10063 10132 Error rate = 1 every 1000, errors = 1004 1019 1049 1011 945 Error rate = 1 every 10000, errors = 90 84 87 79 83 Error rate = 1 every 100000, errors = 0 0 0 0 0
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Math all gone wrong...
by Zaxo (Archbishop) on Dec 01, 2002 at 01:49 UTC | |
by dbp (Pilgrim) on Dec 01, 2002 at 02:25 UTC | |
by CountZero (Bishop) on Dec 01, 2002 at 10:58 UTC | |
|
Re: Math all gone wrong...
by pg (Canon) on Dec 01, 2002 at 01:34 UTC | |
|
Re: Math all gone wrong...
by thewalledcity (Friar) on Dec 01, 2002 at 01:44 UTC | |
|
Re: Math all gone wrong...
by ibanix (Hermit) on Dec 01, 2002 at 03:42 UTC | |
by carlos fandango (Novice) on Dec 01, 2002 at 12:04 UTC | |
by carlos fandango (Novice) on Dec 01, 2002 at 15:34 UTC |