Re: cvs: php4 /ext/standard rand_mt.c rand_sys.c
| From: | Andrei Zmievski | Date: | Wed, 05 Sep 2001 21:48:02 +0000 |
| Subject: | Re: cvs: php4 /ext/standard rand_mt.c rand_sys.c | ||
| References: | 1 2 3 4 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-7234@lists.php.net to get a copy of this message | ||
On Wed, 05 Sep 2001, Jeroen van Wolffelaar wrote:
> Just look at the algorithm and you'll see at once it is bogus. Only in the
> special case that one single key is requested it is correct.
> Proving it's bogus is trivial, so I'll leave that as an exercise to the
> reader (I'm serious).
A little less patronizing, please.
<?php
$stats = array();
srand(1000000*(double)microtime());
$input = array('a', 'b', 'c', 'd', 'e');
for ($x = 0; $x < 10000; $x++) {
$rand = array_rand($input, 3);
foreach ($rand as $r)
$stats[$r]++;
}
var_dump($stats);
?>
The distribution comes out pretty even. What exactly are you concerned
with?
-Andrei
* How would this sentence be different if Pi was equal to three? *