note 41695 deleted from function.shuffle by danbrown
| From: | danbrown@php.net | Date: | Fri, 25 Jul 2008 17:40:49 +0000 |
| Subject: | note 41695 deleted from function.shuffle by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142712@lists.php.net to get a copy of this message | ||
Note Submitter: bryan at mcnett dot org
----
The technique described in the following article enables visiting each in a range of integers
exactly once, but in perceptually random order. A reprint of this article appears in Graphics Gems:
http://www.mactech.com/articles/mactech/Vol.06/06.12/SafeDissolve/
It's possible to cheaply permute the order of integers so produced with XOR et al. This may
enable random shuffling of arrays with less guarantee of true randomness, but more guarantee that
the output looks different from the input, which is probably what you want.
The above technique belongs to the family of LFR (Linear Feedback Registers), which have a long
history of providing "enough randomness" at very low cost.