Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get the indices of a permutation where the value of the element is larger than its index
ResourceFunction["PermutationExcedances"][perm] gives the indices i where permi>i in perm={p1,p2,…,pn}. | |
ResourceFunction["PermutationExcedances"][perm,"BitVector"] gives the indices in a "BitVector" data structure. |
Consider the permutation:
| In[1]:= |
Its excedance indices are {1,2,4,6} because p[[1]]=2 >1, p[[2]]=8>2, p[[4]]=5 >4 and p[[6]]=7 >6:
| In[2]:= |
| Out[2]= |
For large permuted lists of integers, it is much more efficient to store the output in a "BitVector" than a list:
| In[3]:= |
| In[4]:= |
| Out[4]= |
| In[5]:= |
| Out[5]= |
| In[6]:= |
| Out[6]= |
MacMahon observed that the descent/ascent number and excedance number are equidistributed, that is, the number of permutations in Sn with j descents equals the number of permutations with j excedances for all j:
| In[7]:= |
The number of permutations with 4 ascents is the same as those with 4 excedances:
| In[8]:= |
| Out[8]= |
| In[9]:= |
| Out[9]= |
All input must be positive integers. Otherwise the function returns unevaluated:
| In[10]:= |
| Out[10]= |
The input must be a permutation of 1 to n, and include all numbers. Otherwise the function returns unevaluated:
| In[11]:= |
| Out[11]= |
This work is licensed under a Creative Commons Attribution 4.0 International License