Learn R Programming

PerMallows (version 1.14)

rdist.perm: Generate a collection of permutations at a given distance

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

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

Value

A sample of permutations at the given distance

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

Examples

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

Run the code above in your browser using DataLab