Skip to content

Peaks ​

The number of peaks of pp: interior positions ii with pi−1<pi>pi+1p_{i-1} < p_i > p_{i+1}.

✓ checked against that system · ! checked, with disagreements (hover a chip)FindStatSt000015via DyckPath✓St001068via DyckPath✓St000768via IntegerComposition✓St000023via Permutation✓
Peaks(p)the peak count of a one-line permutation pp
SageMathenumeratio_stat("Permutation", p, "Peaks")
Typed signatures
TypePackageApplies
(composition | dyck_path | list | motzkin_path | permutation | schroeder_path) -> integer | numbercombinatoricsalways

Domain: Permutation statistics

Details
  • Only interior positions count (1<i<n1 < i < n), so Peaks(p)=0\mathrm{Peaks}(p) = 0 whenever n≤2n \leq 2
  • Peaks and Valleys alternate along the sequence, so they differ by at most 11
  • 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.
  • A separate definition exists for DyckPath (Occurrences of an up step immediately followed by a down step.) but is not the one declared: one head, one owner.
  • A separate definition exists for MotzkinPath (Occurrences of an up step immediately followed by a down step.) but is not the one declared: one head, one owner.
  • A separate definition exists for SchroederPath (Occurrences of an up step immediately followed by a down step.) but is not the one declared: one head, one owner.

Definition

Epsil, as the implementation runs it.

on Permutation, over _x

0 if Length(_x) < 3 else Count(Filter(
                                       Range(2, Length(_x) - 1),
                                       Function(_x[i - 1] < _x[i] && _x[i] >
                                                                     _x[i + 1], i),
                                     ))

on DyckPath, over _x

0 if Length(_x) < 2 else Count(Filter(
                                       Range(1, Length(_x) - 1),
                                       Function(_x[i] == 1 && _x[i + 1] == 0, i),
                                     ))

on IntegerComposition, over _x

0 if Length(_x) < 3 else Count(Filter(
                                       Range(2, Length(_x) - 1),
                                       Function(_x[i - 1] < _x[i] && _x[i] >
                                                                     _x[i + 1], i),
                                     ))

Examples

Basic #

33 at position 2 tops both neighbors

live ↗
InPeaks([2,3,1])\mathrm{Peaks}(\bigl\lbrack2, 3, 1\bigr\rbrack)Out11

monotone increasing has no interior peak

live ↗
InPeaks([1,2,3])\mathrm{Peaks}(\bigl\lbrack1, 2, 3\bigr\rbrack)Out00

the lone peak at position 2

live ↗
InPeaks([1,3,2,4])\mathrm{Peaks}(\bigl\lbrack1, 3, 2, 4\bigr\rbrack)Out11

the one-line word 312312

live ↗
InPeaks(Permutation⁡([3,1,2]))\mathrm{Peaks}({\operatorname{Permutation}}([3, 1, 2]))Out00

the one-line word 312312, as a plain list

live ↗
InPeaks([3,1,2])\mathrm{Peaks}(\bigl\lbrack3, 1, 2\bigr\rbrack)Out00

the one-line word 24132413

live ↗
InPeaks(Permutation⁡([2,4,1,3]))\mathrm{Peaks}({\operatorname{Permutation}}([2, 4, 1, 3]))Out11

the Motzkin path ULUDDLULUDDL

live ↗
InCombinatorialStat(MotzkinPath⁡([1,0,1,−1,−1,0]),Peaks)\mathrm{CombinatorialStat}({\operatorname{MotzkinPath}}([1, 0, 1, -1, -1, 0]), \text{Peaks})Out11

the Schroeder path UUDDUDL2UUDDUDL^2

live ↗
InCombinatorialStat(SchroederPath⁡([1,1,−1,−1,1,−1,2]),Peaks)\mathrm{CombinatorialStat}({\operatorname{SchroederPath}}([1, 1, -1, -1, 1, -1, 2]), \text{Peaks})Out22
Properties #

FindStat's value for [1]

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

Known value · FindStat St000023

FindStat's value for [1,2]

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

Known value · FindStat St000023

FindStat's value for [2,1]

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

Known value · FindStat St000023

About
Examples11
Checked againstSageMath 9 agree
CrosswalkFindStat ×4SageMath

Implementation

mappedsagepackages/oracle/src/mappings.ts

See also: Valleys, Descents, SymmetricGroup