On Thu, 11 Mar 2021 at 19:06, David Bowen <dmb0...@gmail.com> wrote: > > The algorithm for generating a random permutation with a uniform distribution > across all permutations is easy: > for (i=0; i<n; i++) { > swap a[n-i] with a[rand(n-i+1)] > } > > where 0 <= rand(x) < x and a[i] is initially i (see Knuth, Section 3.4.2 > Algorithm P) >
True, but n can be very large, so that might use a lot of memory and involve a lot of pre-processing. Regards, Dean