rperm: Random permutations

View source: R/permfuns.R

rpermR Documentation

Random permutations

Description

Function rperm() creates a word object of random permutations. Function rcyc() creates random permutations comprising a single (group-theoretic) cycle of a specified length. Functions r1cyc() and rgs1() are low-level helper functions.

Usage

rperm(n=10,r=7,moved=NA)
rcyc(n,len,r=len)
r1cyc(len,vec)
rgs1(s)
rgivenshape(n,s,size=sum(s))

Arguments

n

Number of permutations to create

r

Size of permutations

len

Length of cycles in rcyc() and r1cyc()

moved

In function rperm(), integer specifying how many elements can move (that is, how many elements do not map to themselves), with default NA meaning to choose a permutation at random. This is useful if you want a permutation that has a compact cycle representation

vec

Vector of integers to generate a cycle from

s, size

Shape and size of permutations to create

Value

Returns an object of class word

Note

Argument moved specifies a maximum number of elements that do not map to themselves; the actual number of non-fixed elements might be lower (as some elements might map to themselves). You can control the number of non-fixed elements precisely with argument len of function rcyc(), although this will give only permutations with a single (group-theoretic) cycle.

Argument s of function rgivensize() can include 1s (ones). Although length-one cycles are dropped from the resulting permutation, it is sometimes useful to include them to increase the size of the result, see examples.

In function rgivenshape(), if primary argument n is a vector of length greater than 1, it is interpreted as the shape of the permutation, and a single random permutation is returned.

Author(s)

Robin K. S. Hankin

See Also

size

Examples

rperm()
as.cycle(rperm(30,9))
rperm(10,9,2)

rcyc(20,5)
rcyc(20,5,9)

rgivenshape(10,c(2,3))   # size 5
rgivenshape(10,c(2,3,1,1)) # size 7

rgivenshape(1:9)

allpermslike(rgivenshape(c(1,1,3,4)))


permutations documentation built on Sept. 11, 2024, 6:10 p.m.