note 109247 deleted from function.array-rand by danbrown

From: Date: Mon, 16 Jul 2012 16:01:01 +0000
Subject: note 109247 deleted from function.array-rand by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189240@lists.php.net to get a copy of this message
Note Submitter: tim at ramasaig dot com ---- Following up Sebmil's comment of August 2011: I've tried running Sebmil's test script on my computer, and for me the same half-dozen or so keys always appear at the top of the printed list (and the order below that doesn't change much). if I've understood it correctly, that must mean that there is considerable bias in the 'random' selection ? The least selected key is always 23, followed by 26, 21, 32, 24, 4. After that there's a small amount of variation each time the script is run, but 37 always seems to be at the bottom (most selected). Actual values change a bit, but typically 23 => 2120 and 37 => 2790. Sebmil's script is selecting 10 out of 40 keys, and the results may change if fewer (or more) keys are selected. That's what I'll look at next. For many purposes (random selection of images for display on a web site, say), this anomaly may not matter much, but I can see there would be instances where it was important.

« previous php.notes (#189240) next »