Skip to content

Valleys ​

The number of valleys 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)FindStatSt000053via DyckPath✓St001169via DyckPath✓St000353via Permutation✓
Valleys(p)the valley count of a one-line permutation pp
Typed signatures
TypePackageApplies
(dyck_path | list | permutation) -> integer | numbercombinatoricsalways

Domain: Permutation statistics

Details
  • Only interior positions count (1<i<n1 < i < n), so Valleys(p)=0\mathrm{Valleys}(p) = 0 whenever n≤2n \leq 2
  • The local minima, complementary in shape to the local maxima counted by Peaks
  • 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 a down step immediately followed by an up 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] == 0 && _x[i + 1] == 1, i),
                                     ))

Examples

Basic #

11 dips below both neighbors

live ↗
InValleys([3,1,2])\mathrm{Valleys}(\bigl\lbrack3, 1, 2\bigr\rbrack)Out11

monotone increasing has no interior valley

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

the lone valley at position 3

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

the one-line word 312312

live ↗
InValleys(Permutation⁡([3,1,2]))\mathrm{Valleys}({\operatorname{Permutation}}([3, 1, 2]))Out11

the one-line word 312312, as a plain list

live ↗
InValleys([3,1,2])\mathrm{Valleys}(\bigl\lbrack3, 1, 2\bigr\rbrack)Out11

the one-line word 24132413

live ↗
InValleys(Permutation⁡([2,4,1,3]))\mathrm{Valleys}({\operatorname{Permutation}}([2, 4, 1, 3]))Out11
Properties #

FindStat's value for [1,2]

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

Known value · FindStat St000353

FindStat's value for [2,1]

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

Known value · FindStat St000353

FindStat's value for [1,2,3]

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

Known value · FindStat St000353

About
Examples9
CrosswalkFindStat ×3

See also: Peaks, Ascents, SymmetricGroup