Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: A bad shuffle

by itub (Priest)
on Mar 21, 2005 at 17:41 UTC ( #441246=note: print w/replies, xml ) Need Help??

in reply to A bad shuffle

Note that in practice, even with a perfect shuffling algorithm not all permutations will have equal probability when using a typical rand() function. The problem is that your typical rand() function uses an integer as a seed, and the number of possible seeds is tiny compared to the number of permutations for "large" lists (where "large" might mean something greater than 12).

For example, if you are shuffling 52 items, you have 52! or about 10^68 permutations. Compare that to the roughly 10^10 values that are possible for a 32-bit integer!

Replies are listed 'Best First'.
Re^2: A bad shuffle
by Anonymous Monk on Mar 22, 2005 at 09:57 UTC
    Fair enough. But people might be using /dev/random or /dev/urandom to generate their random numbers.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://441246]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2018-05-25 03:52 GMT
Find Nodes?
    Voting Booth?