# FindStat - the Combinatorial Statistic Finder.¶

The FindStat database can be found at http://www.findstat.org .

Fix the following three notions:

• A combinatorial collection is a set $$S$$ with interesting combinatorial properties,
• a combinatorial map is a combinatorially interesting map $$f: S \to S'$$ between combinatorial collections, and
• a combinatorial statistic is a combinatorially interesting map $$s: S \to \ZZ$$.

You can use the sage interface to FindStat to:

• identify a combinatorial statistic from the values on a few small objects,
• obtain more terms, formulae, references, etc. for a given statistic,
• edit statistics and submit new statistics.

To access the database, use findstat:

sage: findstat
The Combinatorial Statistic Finder (http://www.findstat.org/)


AUTHORS:

• Martin Rubey (2015): initial version.

## A guided tour¶

### Retrieving information¶

The most straightforward application of the FindStat interface is to gather information about a combinatorial statistic. To do this, we supply findstat with a list of $$(object, value)$$ pairs. For example:

sage: PM = PerfectMatchings
sage: r = findstat([(m, m.number_of_nestings()) for n in range(6) for m in PM(2*n)]); r    # optional -- internet
0: (St000041: The number of nestings of a perfect matching., [], 1000)
1: (St000042: The number of crossings of a perfect matching., [Mp00116: Kasraoui-Zeng], 1000)
...


The result of this query is a list (presented as a sage.databases.oeis.FancyTuple) of triples. The first element of each triple is a FindStatStatistic $$s: S \to \ZZ$$, the second element a list of FindStatMap’s $$f_i: S_i \to S_{i+1}$$, and the third element is an integer:

sage: (s, list_f, quality) = r[0]                                           # optional -- internet


The precise meaning of the result is as follows:

The composition $$f_n \circ ... \circ f_2 \circ f_1$$ applied to the objects sent to FindStat agrees with $$quality$$ many $$(object, value)$$ pairs of $$s$$ in the database. Moreover, there are no other $$(object, value)$$ pairs of $$s$$ stored in the database, i.e., there is no disagreement of values.

Put differently, if $$quality$$ is not too small it is likely that the statistic sent to FindStat equals $$s \circ f_n \circ ... \circ f_2 \circ f_1$$.

In the case at hand, the list of maps is empty and the integer $$quality$$ equals the number of $$(object, value)$$ pairs passed to FindStat. This means, that the set of $$(object, value)$$ pairs of the statistic $$s$$ as stored in the FindStat database is a superset of the data sent. We can now retrieve the description from the database:

sage: print(s.description())                                                # optional -- internet
The number of nestings of a perfect matching.

This is the number of pairs of edges $((a,b), (c,d))$ such that $a\le c\le d\le b$. i.e., the edge $(c,d)$ is nested inside $(a,b)$...


and check the references:

sage: s.references()                                                        # optional -- internet
0: [1]  de Médicis, A., Viennot, X. G. Moments des $q$-polynômes de Laguerre et la bijection de Foata-Zeilberger [[MathSciNet:1288802]]
1: [2]  Simion, R., Stanton, D. Octabasic Laguerre polynomials and permutation statistics [[MathSciNet:1418763]]...


If you prefer, you can look at this information also in your browser:

sage: findstat(41).browse()                                                 # optional -- webbrowser


Another interesting possibility is to look for equidistributed statistics. Instead of submitting a list of $$(object, value)$$ pairs, we pass a list of pairs $$(objects, values)$$:

sage: r = findstat([(PM(2*n), [m.number_of_nestings() for m in PM(2*n)]) for n in range(5)]); r # optional -- internet
0: (St000041: The number of nestings of a perfect matching., [], 124)
1: (St000042: The number of crossings of a perfect matching., [], 124)
...


This results tells us that the database contains another entry that is equidistributed with the number of nestings on perfect matchings of size at most $$10$$, namely the number of crossings. Note that there is a limit on the number of elements FindStat accepts for a query, which is currently $$1000$$. Queries with more than $$1000$$ elements are truncated.

Let us now look at a slightly more complicated example, where the submitted statistic is the composition of a sequence of combinatorial maps and a statistic known to FindStat. We use the occasion to advertise yet another way to pass values to FindStat:

sage: r = findstat(Permutations, lambda pi: pi.saliances()[0]); r           # optional -- internet
0: ... (St000051: The size of the left subtree of a binary tree., [Mp00069: complement, Mp00061: to increasing tree], 1000)
...
sage: (s, list_f, quality) = next((a,b,c) for a,b,c in r if a.id() == 51)   # optional -- internet


To obtain the value of the statistic sent to FindStat on a given object, apply the maps in the list in the given order to this object, and evaluate the statistic on the result. For example, let us check that the result given by FindStat agrees with our statistic on the following permutation:

sage: pi = Permutation([3,1,4,5,2]); pi.saliances()[0]
3


We first have to find out, what the maps and the statistic actually do:

sage: print(s.description())                                                # optional -- internet
The size of the left subtree of a binary tree.

sage: print(s.code())                                                       # optional -- internet
def statistic(T):
return T[0].node_number()

sage: print(list_f[0].code() + "\r\n" + list_f[1].code())                   # optional -- internet, random
def complement(elt):
n = len(elt)
return elt.__class__(elt.parent(), [n - x + 1 for x in elt])

def increasing_tree_shape(elt, compare=min):
return elt.increasing_tree(compare).shape()


So, the following should coincide with what we sent FindStat:

sage: pi.complement().increasing_tree_shape()[0].node_number()
3


### Editing and submitting statistics¶

Of course, often a statistic will not be in the database:

sage: findstat([(d, randint(1,1000)) for d in DyckWords(4)])                # optional -- internet
a new statistic on Cc0005: Dyck paths


In this case, and if the statistic might be “interesting”, please consider submitting it to the database using FindStatStatistic.submit().

Also, you may notice omissions, typos or even mistakes in the description, the code and the references. In this case, simply replace the value by using FindStatStatistic.set_description(), FindStatStatistic.set_code() or FindStatStatistic.set_references(), and then FindStatStatistic.submit() your changes for review by the FindStat team.

## Classes and methods¶

class sage.databases.findstat.FindStat

The Combinatorial Statistic Finder.

FindStat is a class representing results of queries to the FindStat database. This class is also the entry point to edit statistics and new submissions. Use the shorthand findstat to call it.

INPUT:

One of the following:

• an integer or a string representing a valid FindStat identifier (e.g. 45 or ‘St000045’). The keyword arguments depth and max_values are ignored.
• a list of pairs of the form (object, value), or a dictionary from sage objects to integer values. The keyword arguments depth and max_values are passed to the finder.
• a list of pairs of the form (list of objects, list of values), or a single pair of the form (list of objects, list of values). In each pair there should be as many objects as values. The keyword arguments depth and max_values are passed to the finder.
• a collection and a list of pairs of the form (string, value), or a dictionary from strings to integer values. The keyword arguments depth and max_values are passed to the finder. This should only be used if the collection is not yet supported.
• a collection and a list of pairs of the form (list of strings, list of values), or a single pair of the form (list of strings, list of values). In each pair there should be as many strings as values. The keyword arguments depth and max_values are passed to the finder. This should only be used if the collection is not yet supported.
• a collection and a callable. The callable is used to generate max_values (object, value) pairs. The number of terms generated may also be controlled by passing an iterable collection, such as Permutations(3). The keyword arguments depth and max_values are passed to the finder.

OUTPUT:

An instance of a FindStatStatistic, represented by

• the FindStat identifier together with its name, or

• a list of triples, each consisting of

• the statistic
• a list of strings naming certain maps
• a number which says how many of the values submitted agree with the values in the database, when applying the maps in the given order to the object and then computing the statistic on the result.

EXAMPLES:

A particular statistic can be retrieved by its St-identifier or number:

sage: findstat('St000041')                                              # optional -- internet
St000041: The number of nestings of a perfect matching.

sage: findstat(51)                                                      # optional -- internet
St000051: The size of the left subtree of a binary tree.


The database can be searched by providing a list of pairs:

sage: l = [pi for n in range(7) for pi in Permutations(n)]
sage: q = findstat([(pi, pi.length()) for pi in l], depth=0); q         # optional -- internet, random
0: (St000018: The number of inversions of a permutation., [], 873)


or a dictionary:

sage: p = findstat({pi: pi.length() for pi in l}, depth=0); p           # optional -- internet, random
0: (St000018: The number of inversions of a permutation., [], 873)


Note however, that the results of these two queries need not compare equal, because we compare queries by the data sent, and the ordering of the data might be different.

Another possibility is to send a collection and a function. In this case, the function is applied to the first few objects of the collection:

sage: findstat("Permutations", lambda pi: pi.length(), depth=0)         # optional -- internet
0: (St000018: The number of inversions of a permutation., [], 1000)


To search for a distribution, send a list of lists, or a single pair:

sage: S = PerfectMatchings(10); findstat((S, [pi.number_of_nestings() for pi in S]), depth=0) # optional -- internet
0: (St000041: The number of nestings of a perfect matching., [], 945)
1: (St000042: The number of crossings of a perfect matching., [], 945)...


Note that there is a limit, FINDSTAT_MAX_DEPTH, on the number of elements that may be submitted to FindStat, which is currently 1000. Therefore, the interface tries to truncate queries appropriately, but this may be impossible, especially with distribution searches:

sage: S = Permutations(7); S.cardinality()                              # optional -- internet
5040
sage: findstat((S, [1 for a in S]))                                     # optional -- internet
Traceback (most recent call last):
...
ValueError: After discarding elements not in the range, too few (=0) values remained to send to FindStat.

browse()

Open the FindStat web page in a browser.

EXAMPLES:

sage: findstat.browse()                                             # optional -- webbrowser

login()

Open the FindStat login page in a browser.

EXAMPLES:

sage: findstat.login()                                              # optional -- webbrowser

set_user(name=None, email=None)

Set the user for this session.

INPUT:

• name – the name of the user.
• email – an email address of the user.

This information is used when submitting a statistic with FindStatStatistic.submit().

EXAMPLES:

sage: findstat.set_user(name="Anonymous", email="[email protected]")


Note

It is usually more convenient to login into the FindStat web page using the login() method.

class sage.databases.findstat.FindStatCollection(parent, id, c, sageconstructor_overridden)

A FindStat collection.

FindStatCollection is a class representing a combinatorial collection available in the FindStat database.

Its main use is to allow easy specification of the combinatorial collection when using findstat. It also provides methods to quickly access its FindStat web page (browse()), check whether a particular element is actually in the range considered by FindStat (in_range()), etc.

INPUT:

One of the following:

• a string eg. ‘Dyck paths’ or ‘DyckPaths’, case-insensitive, or
• an integer designating the FindStat id of the collection, or
• a sage object belonging to a collection, or
• an iterable producing a sage object belonging to a collection.

EXAMPLES:

sage: from sage.databases.findstat import FindStatCollection
sage: FindStatCollection("Dyck paths")                                  # optional -- internet
Cc0005: Dyck paths

sage: FindStatCollection(5)                                             # optional -- internet
Cc0005: Dyck paths

sage: FindStatCollection(DyckWord([1,0,1,0]))                           # optional -- internet
Cc0005: Dyck paths

sage: FindStatCollection(DyckWords(2))                                  # optional -- internet
Cc0005: Dyck paths

sage: FindStatCollection(DyckWords)                                     # optional -- internet
Cc0005: Dyck paths

browse()

Open the FindStat web page of the collection in a browser.

EXAMPLES:

sage: from sage.databases.findstat import FindStatCollection
sage: FindStatCollection("Permutations").browse()                   # optional -- webbrowser

first_terms(statistic, max_values=1200)

Compute the first few terms of the given statistic.

INPUT:

• statistic – a callable.
• max_values – the number of terms to compute at most.

OUTPUT:

A list of pairs of the form (object, value).

EXAMPLES:

sage: from sage.databases.findstat import FindStatCollection
sage: c = FindStatCollection("GelfandTsetlinPatterns")              # optional -- internet
sage: c.first_terms(lambda x: 1, max_values=10)                     # optional -- internet, random
[([[0]], 1),
([[1]], 1),
([[2]], 1),
([[3]], 1),
([[0, 0], [0]], 1),
([[1, 0], [0]], 1),
([[1, 0], [1]], 1),
([[1, 1], [1]], 1),
([[2, 0], [0]], 1),
([[2, 0], [1]], 1)]

from_string()

Return a function that returns the object given a FindStat representation.

OUTPUT:

The function that produces the sage object given its FindStat representation as a string.

EXAMPLES:

sage: from sage.databases.findstat import FindStatCollection
sage: c = FindStatCollection("Posets")                              # optional -- internet
sage: p = c.from_string()('([(0, 2), (2, 1)], 3)')                  # optional -- internet
sage: p.cover_relations()                                           # optional -- internet
[[0, 2], [2, 1]]

sage: c = FindStatCollection("Binary Words")                        # optional -- internet
sage: w = c.from_string()('010101')                                 # optional -- internet
sage: w in c._sageconstructor(6)                                    # optional -- internet
True

id()

Return the FindStat identifier of the collection.

OUTPUT:

The FindStat identifier of the collection as an integer.

EXAMPLES:

sage: from sage.databases.findstat import FindStatCollection
sage: c = FindStatCollection("GelfandTsetlinPatterns")              # optional -- internet
sage: c.id()                                                        # optional -- internet
18

id_str()

Return the FindStat identifier of the collection.

OUTPUT:

The FindStat identifier of the collection as a string.

EXAMPLES:

sage: from sage.databases.findstat import FindStatCollection
sage: c = FindStatCollection("GelfandTsetlinPatterns")              # optional -- internet
sage: c.id_str()                                                    # optional -- internet
'Cc0018'

in_range(element)

Check whether an element of the collection is in FindStat’s precomputed range.

INPUT:

• element – a sage object that belongs to the collection.

OUTPUT:

True, if element is used by the FindStat search engine, and False if it is ignored.

EXAMPLES:

sage: from sage.databases.findstat import FindStatCollection
sage: c = FindStatCollection("GelfandTsetlinPatterns")              # optional -- internet
sage: c.in_range(GelfandTsetlinPattern([[2, 1], [1]]))              # optional -- internet
True
sage: c.in_range(GelfandTsetlinPattern([[3, 1], [1]]))              # optional -- internet
True
sage: c.in_range(GelfandTsetlinPattern([[4, 1], [1]]))              # optional -- internet, random
False

is_supported()

Check whether the collection is fully supported by the interface.

EXAMPLES:

sage: from sage.databases.findstat import FindStatCollection
sage: FindStatCollection(1).is_supported()                          # optional -- internet
True

sage: FindStatCollection(24).is_supported()                         # optional -- internet, random
False

name(style='singular')

Return the name of the FindStat collection.

INPUT:

• a string – (default:”singular”) can be “singular”, or “plural”.

OUTPUT:

The name of the FindStat collection, in singular or in plural.

EXAMPLES:

sage: from sage.databases.findstat import FindStatCollection
sage: FindStatCollection("Binary trees").name()                     # optional -- internet
u'Binary tree'

sage: FindStatCollection("Binary trees").name(style="plural")       # optional -- internet
u'Binary trees'

to_string()

Return a function that returns a FindStat representation given an object.

OUTPUT:

The function that produces the string representation as needed by the FindStat search webpage.

EXAMPLES:

sage: from sage.databases.findstat import FindStatCollection
sage: p = Poset((range(3), [[0, 1], [1, 2]]))                       # optional -- internet
sage: c = FindStatCollection("Posets")                              # optional -- internet
sage: c.to_string()(p)                                              # optional -- internet
'([(0, 1), (1, 2)], 3)'

class sage.databases.findstat.FindStatCollections

The class of FindStat collections.

The elements of this class are combinatorial collections in FindStat as of August 2015. If a new collection was added to the web service since then, the dictionary _findstat_collections in this class has to be updated accordingly.

EXAMPLES:

sage: from sage.databases.findstat import FindStatCollections
sage: sorted(c for c in FindStatCollections())                          # optional -- internet
[Cc0001: Permutations,
Cc0002: Integer partitions,
Cc0005: Dyck paths,
Cc0006: Integer compositions,
Cc0007: Standard tableaux,
Cc0009: Set partitions,
Cc0010: Binary trees,
Cc0012: Perfect matchings,
Cc0013: Cores,
Cc0014: Posets,
Cc0017: Alternating sign matrices,
Cc0018: Gelfand-Tsetlin patterns,
Cc0019: Semistandard tableaux,
Cc0020: Graphs,
Cc0021: Ordered trees,
Cc0022: Finite Cartan types,
Cc0023: Parking functions,
Cc0024: Binary words]

Element

alias of FindStatCollection

class sage.databases.findstat.FindStatMap(parent, entry)

A FindStat map.

FindStatMap is a class representing a combinatorial map available in the FindStat database.

The result of a findstat query contains a (possibly empty) list of such maps. This class provides methods to inspect various properties of these maps, in particular code().

INPUT:

• a string containing the FindStat name of the map, or an integer representing its FindStat id.

EXAMPLES:

sage: from sage.databases.findstat import FindStatMap
sage: FindStatMap(71)                                                   # optional -- internet
Mp00071: descent composition
sage: FindStatMap("descent composition")                                # optional -- internet
Mp00071: descent composition

browse()

Open the FindStat web page of the map in a browser.

EXAMPLES:

sage: from sage.databases.findstat import FindStatMap
sage: FindStatMap(62).browse()                                      # optional -- webbrowser

code()

Return the code associated with the map.

OUTPUT:

A string.

EXAMPLES:

sage: from sage.databases.findstat import FindStatMap               # optional -- internet
sage: print(FindStatMap(71).code())                                 # optional -- internet
def descents_composition(elt):
if len(elt) == 0:
return Composition([])
d = [-1] + elt.descents() + [len(elt)-1]
return Composition([ d[i+1]-d[i] for i in range(len(d)-1)])

code_name()

Return the name of the function defined by code().

OUTPUT:

A string.

EXAMPLES:

sage: from sage.databases.findstat import FindStatMap               # optional -- internet
sage: print(FindStatMap(71).code_name())                            # optional -- internet
descents_composition

codomain()

Return the FindStat collection which is the codomain of the map.

OUTPUT:

The codomain of the map as a FindStatCollection.

EXAMPLES:

sage: from sage.databases.findstat import FindStatMap               # optional -- internet
sage: FindStatMap(71).codomain()                                    # optional -- internet
Cc0006: Integer compositions

description()

Return the FindStat description of the map.

OUTPUT:

The description as a string.

EXAMPLES:

sage: m = findstat("Permutations", lambda pi: pi.length())[1][1][0] # optional -- internet
sage: print(m.description())                                        # optional -- internet, random
Let $\sigma \in \mathcal{S}_n$ be a permutation.

Maps $\sigma$ to the permutation $\tau$ such that the major code of $\tau$ is given by the Lehmer code of $\sigma$.

In particular, the number of inversions of $\sigma$ equals the major index of $\tau$.

EXAMPLES:

$[3,4,1,2] \mapsto [3,1,4,2]$

domain()

Return the FindStat collection which is the domain of the map.

OUTPUT:

The domain of the map as a FindStatCollection.

EXAMPLES:

sage: from sage.databases.findstat import FindStatMap               # optional -- internet
sage: FindStatMap(71).domain()                                      # optional -- internet
Cc0001: Permutations

id()

Return the FindStat identifier of the map.

OUTPUT:

The FindStat identifier of the map as an integer.

EXAMPLES:

sage: m = findstat("Permutations", lambda pi: pi.length())[1][1][0] # optional -- internet
sage: m.id()                                                        # optional -- internet
62

id_str()

Return the FindStat identifier of the map.

OUTPUT:

The FindStat identifier of the map as a string.

EXAMPLES:

sage: m = findstat("Permutations", lambda pi: pi.length())[1][1][0] # optional -- internet
sage: m.id_str()                                                    # optional -- internet
'Mp00062'

name()

Return the FindStat name of the map.

OUTPUT:

The name of the map as a string, as used by FindStat.

EXAMPLES:

sage: m = findstat("Permutations", lambda pi: pi.length())[1][1][0] # optional -- internet
sage: m.name()                                                      # optional -- internet
u'inversion-number to major-index bijection'

class sage.databases.findstat.FindStatMaps

The class of FindStat maps.

The elements of this class are combinatorial maps currently in FindStat.

EXAMPLES:

We can print a nice list of maps currently in FindStat, sorted by domain and codomain:

sage: from sage.databases.findstat import FindStatMap, FindStatMaps
sage: for m in sorted(FindStatMaps(), key=lambda m: (m.domain(), m.codomain())):  # optional -- internet, random
....:     print(m.domain().name().ljust(30)+" "+m.codomain().name().ljust(30)+" "+m.name())
Permutation                    Permutation                    cactus evacuation
Permutation                    Permutation                    complement
Permutation                    Permutation                    cycle-as-one-line notation
...

Element

alias of FindStatMap

class sage.databases.findstat.FindStatStatistic(id, first_terms=None, data=None, function=None, code='', sage_code='', collection=None, depth=None)

The class of FindStat statistics.

Do not instantiate this class directly. Instead, use findstat.

browse()

Open the FindStat web page of the statistic in a browser.

EXAMPLES:

sage: findstat(41).browse()                                         # optional -- webbrowser

code()

Return the code associated with the statistic.

OUTPUT:

A string. Contributors are encouraged to submit sage code in the form:

def statistic(x):
...


but the string may also contain code for other computer algebra systems.

EXAMPLES:

sage: print(findstat(1).code())                                     # optional -- internet
def statistic(x):
return sum(1 for _ in x.reduced_words_iterator())

sage: print(findstat(118).code())                                   # optional -- internet, random
(* in Mathematica *)
tree = {{{{}, {}}, {{}, {}}}, {{{}, {}}, {{}, {}}}};
Count[tree, {{___}, {{___}, {{___}, {___}}}}, {0, Infinity}]

collection()

Return the FindStat collection of the statistic.

OUTPUT:

The FindStat collection of the statistic as an instance of FindStatCollection.

EXAMPLES:

sage: findstat(1).collection()                                      # optional -- internet
Cc0001: Permutations

data()

Return the data used for querying the FindStat database.

OUTPUT:

The data provided by the user to query the FindStat database. When the database was searched using an identifier, data is None.

EXAMPLES:

sage: S = Permutations
sage: findstat([(S(n), [randint(1,1000) for pi in S(n)]) for n in range(4)]).data() # optional -- internet
[(Standard permutations of 0, ['[]'], [112]),
(Standard permutations of 1, ['[1]'], [515]),
(Standard permutations of 2, ['[1, 2]', '[2, 1]'], [45, 333]),
(Standard permutations of 3,
['[1, 2, 3]',
'[1, 3, 2]',
'[2, 1, 3]',
'[2, 3, 1]',
'[3, 1, 2]',
'[3, 2, 1]'],
[521, 183, 701, 81, 890, 582])]

description()

Return the description of the statistic.

OUTPUT:

A string, whose first line is used as the name of the statistic.

EXAMPLES:

sage: print(findstat(1).description())                              # optional -- internet
The number of ways to write a permutation as a minimal length product of simple transpositions.

That is, the number of reduced words for the permutation.  E.g., there are two reduced words for $[3,2,1] = (1,2)(2,3)(1,2) = (2,3)(1,2)(2,3)$.

edit(max_values=1200)

Open the FindStat web page for editing the statistic in a browser.

INPUT:

OUTPUT:

• Raise an error if the query has a match with no intermediate combinatorial maps.

EXAMPLES:

sage: s = findstat(DyckWords(4), lambda x: randint(1,1000)); s      # optional -- internet
a new statistic on Cc0005: Dyck paths


The following uses lambda x: randint(1,1000) to produce 14 terms, because min(DyckWords(4).cardinality(), FINDSTAT_MAX_SUBMISSION_VALUES) is 14:

sage: s.submit()                                                    # optional -- webbrowser

first_terms()

Return the first terms of the statistic.

OUTPUT:

A list of pairs of the form (object, value) where object is a sage object representing an element of the appropriate collection and value is an integer. If the statistic is in the FindStat database, the list contains exactly the pairs in the database.

EXAMPLES:

sage: findstat(1).first_terms()                                     # optional -- internet
[([], 1),
([1], 1),
([1, 2], 1),
([2, 1], 1),
([1, 2, 3], 1),
([1, 3, 2], 1),
([2, 1, 3], 1),
...

first_terms_str()

Return the first terms of the statistic in the format needed for a FindStat query.

OUTPUT:

A string, where each line is of the form object => value, where object is the string representation of an element of the appropriate collection as used by FindStat and value is an integer.

EXAMPLES:

sage: findstat(1).first_terms_str()[:9]                             # optional -- internet
'[] => 1\r\n'

function()

Return the function used to compute the values of the statistic.

OUTPUT:

The function used to compute the values of the statistic, or None.

EXAMPLES:

sage: findstat("Permutations", lambda pi: pi.length()).function()   # optional -- internet
<function <lambda> at ...>

generating_functions(style='polynomial')

Return the generating functions of self in a dictionary.

The keys of this dictionary are the levels for which the generating function of self can be computed from the data of this statistic, and each value represents a generating function for one level, as a polynomial, as a dictionary, or as a list of coefficients.

INPUT:

• a string – (default:”polynomial”) can be “polynomial”, “dictionary”, or “list”.

OUTPUT:

• if style is "polynomial", the generating function is returned as a polynomial.
• if style is "dictionary", the generating function is returned as a dictionary representing the monomials of the generating function.
• if style is "list", the generating function is returned as a list of coefficients of the generating function.

EXAMPLES:

sage: st = findstat(18)                                             # optional -- internet

sage: st.generating_functions()                                     # optional -- internet
{2: q + 1,
3: q^3 + 2*q^2 + 2*q + 1,
4: q^6 + 3*q^5 + 5*q^4 + 6*q^3 + 5*q^2 + 3*q + 1,
5: q^10 + 4*q^9 + 9*q^8 + 15*q^7 + 20*q^6 + 22*q^5 + 20*q^4 + 15*q^3 + 9*q^2 + 4*q + 1,
6: q^15 + 5*q^14 + 14*q^13 + 29*q^12 + 49*q^11 + 71*q^10 + 90*q^9 + 101*q^8 + 101*q^7 + 90*q^6 + 71*q^5 + 49*q^4 + 29*q^3 + 14*q^2 + 5*q + 1}

sage: st.generating_functions(style="dictionary")                   # optional -- internet
{2: {0: 1, 1: 1},
3: {0: 1, 1: 2, 2: 2, 3: 1},
4: {0: 1, 1: 3, 2: 5, 3: 6, 4: 5, 5: 3, 6: 1},
5: {0: 1, 1: 4, 2: 9, 3: 15, 4: 20, 5: 22, 6: 20, 7: 15, 8: 9, 9: 4, 10: 1},
6: {0: 1,
1: 5,
2: 14,
3: 29,
4: 49,
5: 71,
6: 90,
7: 101,
8: 101,
9: 90,
10: 71,
11: 49,
12: 29,
13: 14,
14: 5,
15: 1}}

sage: st.generating_functions(style="list")                         # optional -- internet
{2: [1, 1],
3: [1, 2, 2, 1],
4: [1, 3, 5, 6, 5, 3, 1],
5: [1, 4, 9, 15, 20, 22, 20, 15, 9, 4, 1],
6: [1, 5, 14, 29, 49, 71, 90, 101, 101, 90, 71, 49, 29, 14, 5, 1]}

id()

Return the FindStat identifier of the statistic.

OUTPUT:

The FindStat identifier of the statistic (or 0), as an integer.

EXAMPLES:

sage: findstat(1).id()                                              # optional -- internet
1

id_str()

Return the FindStat identifier of the statistic.

OUTPUT:

The FindStat identifier of the statistic (or ‘St000000’), as a string.

EXAMPLES:

sage: findstat(1).id_str()                                          # optional -- internet
'St000001'

modified()

Return whether the statistic was modified.

OUTPUT:

True, if the statistic was modified using set_description(), set_code(), set_references(), etc. False otherwise.

EXAMPLES:

sage: findstat(41).set_description("")                              # optional -- internet
sage: findstat(41).modified()                                       # optional -- internet
True

name()

Return the name of the statistic.

OUTPUT:

A string, which is just the first line of the description of the statistic.

EXAMPLES:

sage: findstat(1).name()                                            # optional -- internet
'The number of ways to write a permutation as a minimal length product of simple transpositions.'


Search the OEIS for the generating function of the statistic.

INPUT:

• search_size (default:32) the number of integers in the sequence. If too big, the OEIS result is corrupted.
• verbose (default:True) if true, some information about the search are printed.

OUTPUT:

EXAMPLES:

sage: st = findstat(18)                                             # optional -- internet

sage: st.oeis_search()                                              # optional -- internet
Searching the OEIS for "1,1  1,2,2,1  1,3,5,6,5,3,1  1,4,9,15,20,22,20,15,9,4,1  1,5,14,29,49,71,90,101"
0: A008302: Triangle of Mahonian numbers T(n,k)...

sage: st.oeis_search(search_size=13)                                # optional -- internet
Searching the OEIS for "1,1  1,2,2,1  1,3,5,6,5,3,1"
0: A008302: Triangle of Mahonian numbers T(n,k)...
1: A115570: Array read by rows: row n (n>= 1) gives the Betti numbers...
2: A187447: Array for all multiset choices...

references()

Return the references associated with the statistic.

OUTPUT:

An instance of sage.databases.oeis.FancyTuple, each item corresponds to a reference.

Todo

Since the references in the database are sometimes not formatted properly, this method is unreliable. The string representation can be obtained via _references.

EXAMPLES:

sage: findstat(1).references()                                      # optional -- internet
0: [1]  Edelman, P., Greene, C. Balanced tableaux [[MathSciNet:0871081]]
1: [2]  Number of simple allowable sequences on 1..n containing the permutation 12...n. [[OEIS:A005118]]
2: [3]  Total number of reduced decompositions for all permutations in S_n. [[OEIS:A246865]]

sage_code()

Return the sage code associated with the statistic.

OUTPUT:

An empty string or a string of the form:

def statistic(x):
...


EXAMPLES:

sage: print(findstat(1).code())                                     # optional -- internet
def statistic(x):
return sum(1 for _ in x.reduced_words_iterator())

set_code(value)

Set the code associated with the statistic.

INPUT:

• a string – contributors are encouraged to submit sage code in the form:

def statistic(x):
...


OUTPUT:

• Raise an error if the query has a match with no intermediate combinatorial maps.

This information is used when submitting the statistic with submit().

EXAMPLES:

sage: s = findstat([(d, randint(1,1000)) for d in DyckWords(4)])    # optional -- internet
sage: s.set_code("def statistic(x):\r\n    return randint(1,1000)") # optional -- internet
sage: print(s.code())                                               # optional -- internet
def statistic(x):
return randint(1,1000)

set_description(value)

Set the description of the statistic.

INPUT:

• a string – the name of the statistic followed by its description on a separate line.

OUTPUT:

• Raise an error, if the query has a match with no intermediate combinatorial maps.

This information is used when submitting the statistic with submit().

EXAMPLES:

sage: s = findstat([(d, randint(1,1000)) for d in DyckWords(4)]); s # optional -- internet
a new statistic on Cc0005: Dyck paths
sage: s.set_description("Random values on Dyck paths.\nNot for submission.")     # optional -- internet
sage: s                                                             # optional -- internet
a new statistic on Cc0005: Dyck paths
sage: s.name()                                                      # optional -- internet
'Random values on Dyck paths.'
sage: print(s.description())                                        # optional -- internet
Random values on Dyck paths.
Not for submission.

set_first_terms(value)

Update the first terms of the statistic.

INPUT:

• a list of pairs of the form (object, value) where object is a sage object representing an element of the appropriate collection and value is an integer.

OUTPUT:

• Raise an error if the query has a match with no intermediate combinatorial maps.

This information is used when submitting the statistic with submit().

set_references(value)

Set the references associated with the statistic.

INPUT:

• a string – the individual references should be separated by FINDSTAT_SEPARATOR_REFERENCES, which is “\r\n”.

OUTPUT:

• Raise an error, if the query has a match with no intermediate combinatorial maps.

This information is used when submitting the statistic with submit().

EXAMPLES:

sage: s = findstat([(d, randint(1,1000)) for d in DyckWords(4)]); s # optional -- internet
a new statistic on Cc0005: Dyck paths
sage: s.set_references("[1] The wonders of random Dyck paths, Anonymous Coward, [[arXiv:1102.4226]].\r\n[2] [[oeis:A000001]]")  # optional -- internet
sage: s.references()                                                # optional -- internet
0: [1] The wonders of random Dyck paths, Anonymous Coward, [[arXiv:1102.4226]].
1: [2] [[oeis:A000001]]

set_sage_code(value)

Set the code associated with the statistic.

INPUT:

• a string – contributors are encouraged to submit sage code in the form:

def statistic(x):
...


OUTPUT:

• Raise an error if the query has a match with no intermediate combinatorial maps.

This information is used when submitting the statistic with submit().

EXAMPLES:

sage: s = findstat([(d, randint(1,1000)) for d in DyckWords(4)])    # optional -- internet
sage: s.set_sage_code("def statistic(x):\r\n    return randint(1,1000)")      # optional -- internet
sage: print(s.sage_code())                                          # optional -- internet
def statistic(x):
return randint(1,1000)

submit(max_values=1200)

Open the FindStat web page for editing the statistic in a browser.

INPUT:

OUTPUT:

• Raise an error if the query has a match with no intermediate combinatorial maps.

EXAMPLES:

sage: s = findstat(DyckWords(4), lambda x: randint(1,1000)); s      # optional -- internet
a new statistic on Cc0005: Dyck paths


The following uses lambda x: randint(1,1000) to produce 14 terms, because min(DyckWords(4).cardinality(), FINDSTAT_MAX_SUBMISSION_VALUES) is 14:

sage: s.submit()                                                    # optional -- webbrowser