Skip to content

LexicographicRank ​

The position of p among the permutations of its size in lexicographic order, counting from 1.

✓ checked against that system · ! checked, with disagreements (hover a chip)FindStatSt000020via Permutation✓
LexicographicRank(p)The position of p among the permutations of its size in lexicographic order, counting from 1.
Typed signatures
TypePackageApplies
(list<integer> | permutation) -> numbercombinatoricsalways

Domain: Permutation statistics

Details
  • Defined over Permutation as an expression in _x, evaluated by compute-engine — the definition IS the implementation.
  • Takes a Permutation, and also a bare list of integers: this reading compares entries with each other rather than with their positions, so it stands on any sequence.
  • One more than the Lehmer code read as a number in the factorial base.

Definition

Epsil, as the implementation runs it.

on Permutation, over _x

1 if Length(_x) < 1 else 1 +
                         Max(Sum(Map(Function(Count(Filter(
                                                            Range(
                                                                   i + 1,
                                                                   Length(_x),
                                                                   1,
                                                                 ),
                                                            Function(_x[j] <
                                                                     _x[i], j),
                                                          )) *
                                              (1 if Length(_x) - i < 2 else Product(Range(1, Length(_x) - i))), i), Range(1, Length(_x)))), 0)

Examples

Basic #

the one-line word 312312

live ↗
InLexicographicRank(Permutation⁡([3,1,2]))\mathrm{LexicographicRank}({\operatorname{Permutation}}([3, 1, 2]))Out55

the one-line word 312312, as a plain list

live ↗
InLexicographicRank([3,1,2])\mathrm{LexicographicRank}(\bigl\lbrack3, 1, 2\bigr\rbrack)Out55

the one-line word 24132413

live ↗
InLexicographicRank(Permutation⁡([2,4,1,3]))\mathrm{LexicographicRank}({\operatorname{Permutation}}([2, 4, 1, 3]))Out1111
Properties #

FindStat's value for [1]

live ↗
InCombinatorialStat(Permutation⁡([1]),LexicographicRank)\mathrm{CombinatorialStat}({\operatorname{Permutation}}([1]), \text{LexicographicRank})Out11

Known value · FindStat St000020

FindStat's value for [1,2]

live ↗
InCombinatorialStat(Permutation⁡([1,2]),LexicographicRank)\mathrm{CombinatorialStat}({\operatorname{Permutation}}([1, 2]), \text{LexicographicRank})Out11

Known value · FindStat St000020

FindStat's value for [2,1]

live ↗
InCombinatorialStat(Permutation⁡([2,1]),LexicographicRank)\mathrm{CombinatorialStat}({\operatorname{Permutation}}([2, 1]), \text{LexicographicRank})Out22

Known value · FindStat St000020

About
Examples6
CrosswalkFindStat