Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

numperm

Get the nth Permutation Vector by Periodic Placement


Description

numperm implicitly numbers all permutations of length olength, returning the permnumth of these.

Usage

numperm(olength, permnum)

Arguments

olength

The number of items to permute

permnum

The number of the permutation to use (in 1:olength!)

Details

The n! permutations on n items can be deterministically ordered via a factorization process in which there are n slots for the first element, n-1 for the second, and n-i for the ith. This fact is quite handy if you want to visit each permutation in turn, or if you wish to sample without replacement from the set of permutations on some number of elements: one just enumerates or samples from the integers on [1,n!], and then find the associated permutation. numperm performs exactly this last operation, returning the permnumth permutation on olength items.

Value

A permutation vector

Note

Permutation search is central to the estimation of structural distances, correlations, and covariances on partially labeled graphs. numperm is hence used by structdist, gscor, gscov, etc.

Author(s)

Carter T. Butts buttsc@uci.edu

See Also

Examples

#Draw a graph
g<-rgraph(5)

#Permute the rows and columns
p.1<-numperm(5,1)
p.2<-numperm(5,2)
p.3<-numperm(5,3)
g[p.1,p.1]
g[p.2,p.2]
g[p.3,p.3]

sna

Tools for Social Network Analysis

v2.6
GPL (>= 2)
Authors
Carter T. Butts [aut, cre, cph]
Initial release
2020-10-5

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.