in reply to Re^2: Shuffling CODONS
in thread Shuffling CODONS
... uniform random number between 1 and N; where N is the number of elements in the array ...Correction: several such random numbers. Alternatively, one random number 1..N, where N is the number of permutations.
The shuffle algorithm needs a random number sequence of finite length. A PRNG with 48 bits of internal state can generate at most 248 different sequences (of some particular length), because it is deterministic. If there are more permutations than that, some will never be selected.
Those using GNU/Linux can take a quick glimpse at the working of the standard shuffle tool, shuf.
$ strace -s0 -e open,read shuf -o /dev/null -i 1-17
...
open("/dev/urandom", O_RDONLY) = 3
read(3, ""..., 11) = 11
...
$ strace -s0 -e open,read shuf -o /dev/null -i 1-1000
...
open("/dev/urandom", O_RDONLY) = 3
read(3, ""..., 1250) = 1250
...
Here, in order to shuffle a list of integers 1-17, shuf actually wants 11 random bytes. For 1000 elements, shuf reads 1250 bytes of /dev/urandom.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Shuffling CODONS
by BrowserUk (Patriarch) on Jun 08, 2018 at 20:04 UTC |