Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get the index of a list of integers in standard order
ResourceFunction["StandardOrderIndex"][list] gives the index of a list of integers in standard order. |
| {1,2,2,1,3,2,1,4,3} | integers >0 in standard order start with 1, then can never be more than 1 higher than all previous integers. |
| {1,2,0,0,3,0,0,4,0} | some of the digits are new highest digits. |
| {0,0,2,1,0,2,1,0,3} | other digits acquire a mixed radix based on the previous highest digit. |
| {1,0,0,1,0,0,1,0} | without the initial 1, the sequence of highest digits mapped to 1 values makes a binary number B. |
| 223241 | any binary number with 1's→{2,…,n} and sequential zeros acting as powers gives a Bell index. |
| BellB[n] | equals the sum of Bell indices of length n-1 binary numbers. |
| {146, 86}->5867 | the total of the first B Bell indices plus the mixed radix value gives the index. |
Find the index of a standard order:
| In[1]:= |
| Out[1]= |
Index of a larger standard order:
| In[2]:= |
| Out[2]= |
Define a Bell indexing function:
| In[3]:= | ![]() |
The total number of standard orders of length n is given by BellB[n] or the total of the Bell indices with the last standard order being Range[n]:
| In[4]:= |
| Out[4]= |
If a list isn’t in standard order it will be put into standard order before the indexing. Here is a random list:
| In[5]:= |
| Out[5]= |
Here is its index:
| In[6]:= |
| Out[6]= |
Define a standard ordering function:
| In[7]:= | ![]() |
Order the random list:
| In[8]:= |
| Out[8]= |
Compare the index of the unordered version with that of the ordered one:
| In[9]:= |
| Out[9]= |
Some auxiliary functions:
| In[10]:= | ![]() |
Here are the 52 standard orders of length 5:
| In[11]:= |
| Out[11]= | ![]() |
Give the indices of these standard orders:
| In[12]:= |
| Out[12]= |
A particular standard order:
| In[13]:= |
| Out[13]= |
Recover that data using the StandardOrders function:
| In[14]:= |
| Out[14]= |
Find the index of a standard order:
| In[15]:= |
| Out[15]= |
Define a Bell indexing function:
| In[16]:= | ![]() |
Here is how the function finds the index:
| In[17]:= | ![]() |
| Out[17]= |
For length n, 2n indices need to be generated, so this function will start slowing down at length 20:
| In[18]:= |
| Out[18]= |
There are lots of standard orders of length 20:
| In[19]:= |
| Out[19]= |
This work is licensed under a Creative Commons Attribution 4.0 International License