derangement | R Documentation |
A derangement is a permutation which leaves no element fixed.
is.derangement(x)
x |
Object to be tested |
A vector of Booleans corresponding to whether the permutations are derangements or not.
The identity permutation is problematic because it potentially has zero size.
The identity element is not a derangement, although the (zero-size) identity
cycle and permutation both return TRUE
under the natural R idiom
all(P != seq_len(size(P)))
.
Robin K. S. Hankin
id
allperms(4)
is.derangement(allperms(4))
M <- matrix(c(1,2,3,4, 2,3,4,1, 3,2,4,1),byrow=TRUE,ncol=4)
M
is.derangement(word(M))
is.derangement(rperm(16,4))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.