InversionSum
The sum of j - i over the inversions i < j.
✓ checked against that system · ! checked, with disagreements (hover a chip)FindStat
St000347via BinaryWord✓St000055via Permutation✓InversionSum(p)The sum of j - i over the inversions i < j.Typed signatures
| Type | Package | Applies |
|---|---|---|
(binary_word | list<integer> | permutation) -> number | combinatorics | always |
Details
- 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(Sum(Map(
Function(j - i, j),
Filter(
Range(
i + 1,
Length(_x),
),
Function(
_x[i] >
_x[j] && True,
j,
),
),
)), i),
Range(1, Length(_x) - 1),
))on BinaryWord, over _x
0 if Length(_x) < 2 else Max(Sum(Map(
Function(Max(Sum(Map(
Function((j - i) *
(1 if _x[i] >
_x[j] else 0), j),
Range(
i + 1,
Length(_x),
1,
),
)), 0), i),
Range(1, Length(_x) - 1),
)), 0)Examples
Basic #
Properties #
About
| Examples | 6 |
|---|---|
| Crosswalk | FindStat ×2 |