rdist: Generate a collection of permutations at a given distance

Description Usage Arguments Value Examples

View source: R/PerMallows.R

Description

Given a number of permutations, the number of items in the permutations, a distance value and a distance name, generate a sample of permutations with the specified length at the given distance. Can be used to generate derangements and permutations of a given number of cycles

Usage

1
rdist(n, perm.length, dist.value, dist.name = "kendall")

Arguments

n

number of permutations in the sample

perm.length

number of items in the permutations

dist.value

distance value

dist.name

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

Value

A sample of permutations at the given distance

Examples

1
2
3
4
5
6
rdist(1, 4, 2 ) 
rdist(1, 4, 2, "ulam")
len <-  3
rdist(n = 1, perm.length = len, dist.value = len, "h") #derangement
cycles <- 2
rdist(n = 1, perm.length = len, dist.value = len - cycles, "c") #permutation with 2 cycles

Example output

Loading required package: Rcpp
     [,1] [,2] [,3] [,4]
[1,]    2    1    4    3
     [,1] [,2] [,3] [,4]
[1,]    2    1    4    3
     [,1] [,2] [,3]
[1,]    2    3    1
     [,1] [,2] [,3]
[1,]    3    2    1

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

Related to rdist in PerMallows...