12,217 research outputs found

    Efficient generation of random derangements with the expected distribution of cycle lengths

    Full text link
    We show how to generate random derangements efficiently by two different techniques: random restricted transpositions and sequential importance sampling. The algorithm employing restricted transpositions can also be used to generate random fixed-point-free involutions only, a.k.a. random perfect matchings on the complete graph. Our data indicate that the algorithms generate random samples with the expected distribution of cycle lengths, which we derive, and for relatively small samples, which can actually be very large in absolute numbers, we argue that they generate samples indistinguishable from the uniform distribution. Both algorithms are simple to understand and implement and possess a performance comparable to or better than those of currently known methods. Simulations suggest that the mixing time of the algorithm based on random restricted transpositions (in the total variance distance with respect to the distribution of cycle lengths) is O(nalogn2)O(n^{a}\log{n}^{2}) with a12a \simeq \frac{1}{2} and nn the length of the derangement. We prove that the sequential importance sampling algorithm generates random derangements in O(n)O(n) time with probability O(1/n)O(1/n) of failing.Comment: This version corrected and updated; 14 pages, 2 algorithms, 2 tables, 4 figure

    Random and exhaustive generation of permutations and cycles

    Full text link
    In 1986 S. Sattolo introduced a simple algorithm for uniform random generation of cyclic permutations on a fixed number of symbols. This algorithm is very similar to the standard method for generating a random permutation, but is less well known. We consider both methods in a unified way, and discuss their relation with exhaustive generation methods. We analyse several random variables associated with the algorithms and find their grand probability generating functions, which gives easy access to moments and limit laws.Comment: 9 page
    corecore