@@ -186,6 +186,93 @@ You can get its enumeration up to a fixed length.
186
186
>> > perm_class.count(11 )
187
187
1024
188
188
189
+ You can also look to see if some well know enumeration strategies apply to a
190
+ given class.
191
+
192
+ .. code-block :: python
193
+
194
+ >> > from permuta.enumeration_strategies import find_strategies
195
+ >> > basis = [Perm((3 , 2 , 0 , 1 )), Perm((1 , 0 , 2 , 3 ))]
196
+ >> > for strat in find_strategies(basis):
197
+ ... print (strat.reference())
198
+ The insertion encoding of permutations: Corollary 10
199
+ >> > basis = [Perm((1 , 2 , 0 , 3 )), Perm((2 , 0 , 1 , 3 )), Perm((0 , 1 , 2 , 3 ))]
200
+ >> > for strat in find_strategies(basis):
201
+ ... print (strat.reference())
202
+ Enumeration of Permutation Classes and Weighted Labelled Independent Sets: Corollary 4.3
203
+
204
+ Permutation statistics
205
+ ######################
206
+
207
+ With the ``PermutationStatistic `` class we can look for distributions of statistics for
208
+ classes and look for statistics preservations (or transformation) either for two classes
209
+ or given a bijection. First we need to import it.
210
+
211
+ .. code-block :: python
212
+
213
+ >> > from permuta.permutils.statistics import PermutationStatistic
214
+
215
+ To see a distribution for a given statistic we grab its instance and provide a length
216
+ and a class (no class will use the set of all permutations).
217
+
218
+ .. code-block :: python
219
+
220
+ >> > PermutationStatistic.show_predefined_statistics() # Show all statistics with id
221
+ [0 ] Number of inversions
222
+ [1 ] Number of non- inversions
223
+ [2 ] Major index
224
+ [3 ] Number of descents
225
+ [4 ] Number of ascents
226
+ [5 ] Number of peaks
227
+ [6 ] Number of valleys
228
+ [7 ] Number of cycles
229
+ [8 ] Number of left- to- right minimas
230
+ [9 ] Number of left- to- right maximas
231
+ [10 ] Number of right- to- left minimas
232
+ [11 ] Number of right- to- left maximas
233
+ [12 ] Number of fixed points
234
+ [13 ] Order
235
+ [14 ] Longest increasing subsequence
236
+ [15 ] Longest decreasing subsequence
237
+ [16 ] Depth
238
+ >> > depth = PermutationStatistic.get_by_index(16 )
239
+ >> > depth.distribution_for_length(5 )
240
+ [1 , 4 , 12 , 24 , 35 , 24 , 20 ]
241
+ >> > depth.distribution_up_to(4 , Av.from_string(" 123" ))
242
+ [[1 ], [1 ], [1 , 1 ], [0 , 2 , 3 ], [0 , 0 , 3 , 7 , 4 ]]
243
+
244
+ Given a bijection as a dictionary, we can check which statistics are preserved with
245
+ ``check_all_preservations `` and which are transformed with ``check_all_transformed ``
246
+
247
+ .. code-block :: python
248
+
249
+ >> > bijection = {p: p.reverse() for p in Perm.up_to_length(5 )}
250
+ >> > for stat in PermutationStatistic.check_all_preservations(bijection):
251
+ ... print (stat)
252
+ Number of peaks
253
+ Number of valleys
254
+
255
+ We can find all (predefined) statistics equally distributed over two permutation
256
+ classes with ``equally_distributed ``. We also support checks for joint distribution
257
+ of more than one statistics with ``jointly_equally_distributed `` and transformation
258
+ of jointly distributed stats with ``jointly_transformed_equally_distributed ``.
259
+
260
+ .. code-block :: python
261
+
262
+ >> > cls1 = Av.from_string(" 2143,415263" )
263
+ >> > cls2 = Av.from_string(" 3142" )
264
+ >> > for stat in PermutationStatistic.equally_distributed(cls1, cls2, 6 ):
265
+ ... print (stat)
266
+ Major index
267
+ Number of descents
268
+ Number of ascents
269
+ Number of peaks
270
+ Number of valleys
271
+ Number of left- to- right minimas
272
+ Number of right- to- left maximas
273
+ Longest increasing subsequence
274
+ Longest decreasing subsequence
275
+
189
276
The BiSC algorithm
190
277
==================
191
278
0 commit comments