is introduced if the number of return values of random() is not a multiple of m, but this becomes insignificant if the number of return values of random() is orders of magnitude greater than m. Statistics on random permutations Fixed points The probability distribution of the number of fixed points in a uniformly distributed random permutation approaches a Poisson distribution with expected value 1 as n grows. In particular, it is an elegant application of the inclusion–exclusion principle to show that the probability that there are no fixed points approaches 1/e. When n is big enough, the probability distribution of fixed points is almost the Poisson distribution with expected value 1. The first n moments of this distribution are exactly those of the Poisson distribution. Randomness testing As with all random processes, the quality of the resulting distribution of an implementation of a randomized algorithm such as the Knuth shuffle (i.e., how close it is to the desired uniform distribution) depends on the quality of the underlying source of randomness, such as a pseudorandom number generator. There are many possible randomness tests for random permutations, such as some of the Diehard tests. A typical example of such a test is to take some permutation statistic for which the distribution is known and test whether the distribution of this statistic on a set of randomly generated permutations closely approximates the true distribution. See also Ewens's sampling formula — a connection with population genetics Faro shuffle Golomb–Dickman constant Random permutation statistics Shuffling algorithms — random sort method, iterative exchange method Pseudorandom permutation References External links Random permutation at MathWorld 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 Permutations Randomized algorithms