Hi Franco and all! On Fri, Jul 29, 2011 at 08:58:01PM -0700, Anne Schilling wrote: > >Christian Stump, Chris Berg and I have been thinking about statistics > >on combinatorial objects in Sage. There are several already > >implemented in Sage, and we think that it would be very useful to have > >a means to identify. As a simple example, one might want to know all > >the statistics that are implemented for permutations (or tableaux, or > >words, or k-ratonslaveurs, ...) in order to output a table of values > >of these statistics. > > > >So the question is: how do we do this? We have been toying with the > >idea of implementing a decorator (like cached_method) for methods that > >are statistics. It would take as an argument the codomain of the > >statistic. Knowing the codomain would make it possible to ask for all > >integer-valued statistics, say. A typical example would be > >permutations and integer statistics: > > > > @combinatorial_statistic(codomain=Integers) > > def major_index(self): > > return ... > > > >Comments? Suggestions? Alternative ideas for implementations?
Here are some questions that might help guide the design. I threw in each time some possible choices of syntax. Other choices are certainly possible, while some choices are mutually incompatible. For short, I used ``statistic'' rather than ``combinatorial statistic'', but I don't have an opinion on which is best. - How do we want to define (mathematically) a statistic? A simple possibility: a function taking a single input in some enumerated set, and with output in some codomain, typically a ring, typically Integer. - How do we want to model a statistic? As a specific object in some CombinatorialStatistic class? Or just as a standard python function/method? In the later case, and if we want to use introspection to discover the implemented statistics, we probably need to attach some extra signature information to the function. Python 3 will allow for specifying the signature of a function/method, i.e. the "types" of the input and output of a function (see ....). In the mean time, we could implement (or better find on the internet) a general purpose decorator for (partially) specifying such signatures: @signature(domain=Partitions(), codomain=ZZ) def my_statistic(self): ... - What are the operations on statistics? - Fetch / construct a statistic from its name, and a set: sage: length = Permutations(5).statistic('length') sage: length = Permutations(5).length sage: length = Permutations(5).element_class.length sage: length = Permutations(5).statistics()['length'] sage: length = attrcall('length') - Compute a statistic on a single object: sage: p.length() sage: length(p) - Compute the generating series of some set according to some (or several!) statistic sage: Permutations(5).generating_series(z, length) sage: length.generating_series(Permutations(5), z) - Get all objects in Permutations(5) with given value for a given statistic: sage: Permutations(5).subset(length=3) - Discover all statistics implemented on a given set: sage: Permutations(5).statistics() {'length': ..., 'major_index': ...} sage: Permutations(5).statistics(output=ZZ) {'length': ..., 'major_index': ...} - Discover all statistics implemented in Sage: Do we really need this feature? In Anne's use case, it seems to be sufficient to request the statistics defined on the set of rigged configurations and on the corresponding crystal. Otherwise, see e.g. the code of sage.misc.classgraph for how to explore all Sage's classes. And we could put it in something like: sage: Sets().statistics() - Compare two statistics for equidistribution - Test if a bijection preserves given statistics - Discover all statistics that are preserved/transported through a bijection. - (Advanced) use statistics to semi-automatically guide the discovery of bijections between two set. - ... I though that I had more of those operations, but they got lost in a battery outage when I first wrote this e-mail three weeks ago. Please fill in! Cheers, Nicolas -- Nicolas M. ThiƩry "Isil" <nthi...@users.sf.net> http://Nicolas.Thiery.name/ -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To post to this group, send email to sage-combinat-devel@googlegroups.com. To unsubscribe from this group, send email to sage-combinat-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sage-combinat-devel?hl=en.