Efficient uniform generation of random derangements with the expected distribution of cycle lengths
We show how to generate random derangements with the expected distribution of cycle lengths by two different techniques: random restricted transpositions and sequential importance sampling. The algorithms are simple to understand and implement and possess a performance comparable to or better than those of currently known methods. Our data suggest that the mixing time (in the total variance distance) of the algorithm based on random restricted transpositions is O(n^an^2) with a ≃1/2 and n the size of the derangement. For the sequential importance sampling algorithm we prove that it generates random derangements in O(n) time with a small probability O(1/n) of failing.
READ FULL TEXT