Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://441246]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2016-06-27 02:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (335 votes). Check out past polls.