- Random permutation
A random permutation is a
random ordering of a set of objects, that is, apermutation -valuedrandom variable . The use of random permutations is often fundamental to fields that userandomized algorithm s. Such fields includecoding theory ,cryptography , andsimulation . A good example of a random permutation is theshuffling of a deck of cards: this is ideally a random permutation of the 52 cards.One method of generating a random permutation of a set of length "n" uniformly at random (i.e. each of the "n"!
permutation s is equally likely to appear) is to generate a sequence by taking a random number between 1 and "n" sequentially, ensuring that there is no repetition, and interpreting this sequence {"x"1, ..., "x""n"} as the permutation:
The above brute-force method will require occasional retries whenever the random number picked is a repeat of a number already selected. A simple
algorithm to generate a permutation of "n" items uniformly at random without retries, known as theKnuth shuffle , is to start with the identity permutation or any other permutation, and then go through the positions 1 through "n"−1, and for each position "i" swap the element currently there with an arbitrarily chosen element from positions "i" through "n", inclusive. It's easy to verify that any permutation of "n" elements will be produced by this algorithm with probability exactly 1/"n"!, thus yielding a uniform distribution over all such permutations.For an account of the
probability distribution of the number offixed point s of a uniformly distributed random permutation, seerencontres numbers . That distribution approaches aPoisson distribution withexpected value 1 as "n" grows. In particular, it is an elegant application of theinclusion-exclusion principle to show that the probability that there are no fixed points approaches 1/"e". The first "n" moments of this distribution are exactly those of the Poisson distribution.See
Ewens's sampling formula for a connection withpopulation genetics .See also
*
Golomb–Dickman constant
*Perfect shuffle
*Random permutation statistics
* Shuffling algorithms — random sort method, iterative exchange methodExternal links
* [http://mathworld.wolfram.com/RandomPermutation.html Random permutation] at
MathWorld
* [http://www.techuser.net/randpermgen.html Random permutation generation] -- detailed and practical explanation of Knuth shuffle algorithm and its variants for generating k-permutations (permutations of k elements chosen from a list) and k-subsets (generating a subset of the elements in the list without replacement) with pseudocode
Wikimedia Foundation. 2010.