[erlang-questions] Speedy unsort:shuffle/1,2 ?

Richard O'Keefe ok@REDACTED
Fri May 28 01:27:25 CEST 2010


On May 28, 2010, at 1:12 AM, Björn-Egil Dahlberg wrote:
> Is there no need for assigning unique numbers to the list when  
> sorting it? I guess it boils down to how fair we want the list to be  
> unsorted (or how one wants to word it).

If we really had something generating 53-bit random floats,
the changes that a million-element list would get at least one
duplicate would be
	1 - (1 - 2**-53)**1,000,000
or roughly 2**-33.  Or put it another way: stop worrying.  The
RNG that Erlang uses has worse problems than that.  It was
great for its purpose in Quintus Prolog >25 years ago, but it
has long since been surpassed.

Put another way, the problem of assigning unique numbers
*is* the problem of generating random permutations (wearing
a wig and a false nose).



More information about the erlang-questions mailing list