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
    Correction: several such random numbers. Alternatively, one random number 1..N, where N is the number of permutations.

    Still garbage!

    A PRNG with 48 bits of internal state can generate at most 248 different sequences

    You really believe that? Then tell me, how is it that the 32-bit Mersenne Twister has a period of 219937 − 1?

    You really don't have a clue do you. No wonder you hide in anonymity.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
    In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit