gives a pseudorandom permutation in the permutation group gr.
RandomPermutation[gr,n]
gives a list of n pseudorandom permutations in the permutation group gr.
RandomPermutation
gives a pseudorandom permutation in the permutation group gr.
RandomPermutation[gr,n]
gives a list of n pseudorandom permutations in the permutation group gr.
Details
- Permutations are returned with uniform distribution in the given group.
- The result is given in disjoint cyclic form, with head Cycles.
- RandomPermutation[d] and RandomPermutation[d,n] return permutations in the symmetric group of degree d.
- RandomPermutation gives a different sequence of pseudorandom permutations whenever you run the Wolfram Language. You can start with a particular seed using SeedRandom.
- A Method option to SeedRandom can be given to specify the pseudorandom generator used.
Examples
open all close allBasic Examples (2)
Scope (1)
Generate 10000 random permutations in a group:
perms = RandomPermutation[PermutationGroup[{Cycles[{{1, 2}}], Cycles[{{1, 3}, {2, 4}}], Cycles[{{3, 5}, {4, 6}}]}], 10000];They are generated with uniform distribution:
ListPlot[Last /@ Tally[perms], PlotRange -> {0, 300}]Properties & Relations (3)
With degrees 0 or 1, or using the trivial group, you always get the identity permutation:
RandomPermutation[0]RandomPermutation[1]RandomPermutation[PermutationGroup[{}]]RandomPermutation[SymmetricGroup[1]]RandomPermutation[AlternatingGroup[2]]Use SeedRandom to get repeatable random permutations:
{RandomPermutation[5], RandomPermutation[5]}{SeedRandom[1234];RandomPermutation[5], SeedRandom[1234];RandomPermutation[5]}Use BlockRandom to block one use of RandomPermutation from affecting others:
{BlockRandom[RandomPermutation[5]], RandomPermutation[5]}See Also
Cycles RandomChoice RandomSample SeedRandom BlockRandom GroupElements
Function Repository: RandomDerangement
Tech Notes
Related Guides
History
Text
Wolfram Research (2010), RandomPermutation, Wolfram Language function, https://reference.wolfram.com/language/ref/RandomPermutation.html.
CMS
Wolfram Language. 2010. "RandomPermutation." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RandomPermutation.html.
APA
Wolfram Language. (2010). RandomPermutation. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RandomPermutation.html
BibTeX
@misc{reference.wolfram_2026_randompermutation, author="Wolfram Research", title="{RandomPermutation}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/RandomPermutation.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_randompermutation, organization={Wolfram Research}, title={RandomPermutation}, year={2010}, url={https://reference.wolfram.com/language/ref/RandomPermutation.html}, note=[Accessed: 12-June-2026]}