Inversions
The number of inversions of a permutation : pairs with (its Kendall-tau distance from the identity).
✓ checked against that system · ! checked, with disagreements (hover a chip)Wikipedia
Inversion (discrete mathematics)MathWorldPermutationInversionWikidataQ1368009FindStatSt000293via BinaryWord✓St000766via IntegerComposition✓St000018via Permutation✓Inversions(p)the inversion count of a one-line permutation Combinatorica
Inversions[p]SageMathenumeratio_stat("Permutation", p, "Inversions")Typed signatures
| Type | Package | Applies |
|---|---|---|
(binary_word | composition | list | permutation) -> integer | number | combinatorics | always |
Details
- Ranges from (the identity) to (the reversal )
- Generating function over is the q-factorial
- Equidistributed with MajorIndex on (MacMahon), so both are Mahonian statistics
- Aggregates over a whole collection compose from built-ins: folds the stat over the lazy family
- Defined over
Permutationas 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.
Definition
Epsil, as the implementation runs it.
on Permutation, over _x
0 if Length(_x) < 2 else Sum(Map(
Function(
Count(Filter(
Range(
i + 1,
Length(_x),
),
Function(
_x[i] >
_x[j],
j,
),
)),
i,
),
Range(1, Length(_x)),
))on IntegerComposition, over _x
0 if Length(_x) < 2 else Sum(Map(Function(
Count(Filter(Range(
i + 1,
Length(_x),
1,
), Function(_x[i] >
_x[j], j))),
i,
), Range(1, Length(_x) - 1)))on BinaryWord, over _x
0 if Length(_x) < 2 else Sum(Map(Function(
Count(Filter(Range(
i + 1,
Length(_x),
1,
), Function(_x[i] >
_x[j], j))),
i,
), Range(1, Length(_x) - 1)))Examples
Basic #
Applications #
Properties #
About
| Examples | 12 |
|---|---|
| Checked against | Combinatorica 7 agreeSageMath 9 agreemathlib4 6 agree |
| Crosswalk | WikipediaMathWorldWikidataFindStat ×3CombinatoricaSageMath |
Implementation
mapped
combinatoricapackages/oracle/src/mappings.tsmapped
sagepackages/oracle/src/mappings.tsmapped
mathlib4packages/oracle/src/mappings.tsPairs i < j with l[i] > l[j], counted over Fin pairs of the list; a permutation word and a plain list agree, a composition (which has its own inversions) does not
See also: MajorIndex, Descents, SymmetricGroup