Subject: Re: make a list of different random numbers
From: (Rob Warnock)
Date: Wed, 18 Feb 2009 06:16:12 -0600
Newsgroups: comp.lang.lisp
Message-ID: <>
Madhu <> wrote:
| * (Rob Warnock) <> :
| | Marco Antoniotti  <> wrote:
| I suspect both of these functions are likely to produce "less than
| random" results, [although I doubt it would be a concern to the OP] I
| think a small bias is introduced in sampling the uniform random process
| producing the numbers.

Indeed. We had a long discussion about that here about three years ago,
and at that time I even observed that:

   The pages <>
   and <>[1] contain
   comments on & references to why you don't want to do this. Briefly;
      Note: Attaching random tags then sorting (see permutation)
      may not be a perfect shuffle: if tags may be duplicated, a
      stable sort has a greater chance of producing permutations
      with some items in the original order.

A Fisher-Yates shuffle in an array initialized to (IOTA BOUND)
would be truly random, and if the desired output sequence LENGTH
were close to BOUND it would probably be near-optimal in performance
as well [certainly much better than either Marco's or my functions].

On the other hand, if LENGTH << BOUND, then the non-randomness of
Marco's or my functions due to the chance of duplicates will be small,
and the performance will be much better than Fisher-Yates.


[1] Actually, the page I quoted in March 2006 was the following one,
    which has since been replaced by the one referenced above:

Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607