count.perms: Count permutations at a distance

Description Usage Arguments Value Examples

View source: R/PerMallows.R

Description

Given a distance (kendall, cayley, hamming or ulam), the number of items in the permutations perm.length and distance value d, how many permutations are there at distance d from any permutation? It can be used to count the number of derangements and the permutations with k cycles (Stirling numbers of the first kind)

Usage

1
count.perms(perm.length, dist.value, dist.name = "kendall", disk = FALSE)

Arguments

perm.length

number of items in the permutations

dist.value

the distance

dist.name

optional. One of: kendall (default), cayley, hamming, ulam

disk

optional can only be true if counting the permutations at each Ulam distance. Insted of generating the whole set of SYT and count of permutations per distance, it loads the info from a file in the disk

Value

The number of permutations at the given distance

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
count.perms(4,2,"kendall")
count.perms(4,2,"ulam")
count.perms(4,2,"hamming")
count.perms(4,2,"cayley")
# The number of derangements of length 6 is computed as follows
len <- 6
count.perms(perm.length = len, dist.value = len, dist.name = "h") 
# The number of permutations with one cycle is computed as follows
num.cycles <- 1 
count.perms(perm.length = len, dist.value = len - num.cycles, dist.name = "c") 

Example output

Loading required package: Rcpp
[1] 5
[1] 13
[1] 6
[1] 11
[1] 265
[1] 120

PerMallows documentation built on May 2, 2019, 6:14 a.m.