getpermutationnumber {TUGLab}R Documentation

Get permutation number

Description

Given a permutation, this function returns its position in the Lehmer code order.

Usage

getpermutationnumber(permutation)

Arguments

permutation

A permutation, as a vector.

Details

The Lehmer code makes use of the fact that there are n! permutations of a sequence of n numbers. If a permutation \sigma is specified by the sequence (\sigma_{i})_{i=1}^{n}, its Lehmer code is the sequence L(\sigma)=(L(\sigma)_{i})_{i=1}^{n}, where L(\sigma)_i=|\{j>i:\sigma_j<\sigma_i\}|.

The position of permutation \sigma according to the Lehmer code order is

L_{\sigma}=1 + \sum_{i=1}^{n} (n-i)! L(\sigma)_i

.

Value

The position of the permutation according to the Lehmer code order, as an integer.

See Also

getpermutation

Examples

getpermutationnumber(c(1, 2, 5, 4, 3))

[Package TUGLab version 0.0.1 Index]