[Python-ideas] thoughts on the new 3.4 statistics module

MRAB python at mrabarnett.plus.com
Wed Dec 25 04:15:04 CET 2013


On 25/12/2013 00:47, Steven D'Aprano wrote:
> Hi Wolfgang, and thanks for the feedback! My responses below.
>
> On Sat, Dec 21, 2013 at 02:29:14PM -0800, Wolfgang wrote:
>
>> First: I am not entirely convinced by when the module raises Errors. In
>> some places its undoubtedly justified to raise StatisticsError (like when
>> empty sequences are passed to mean()).
>> On the other hand, should there really be an error, when for example no
>> unique value for the mode can be found?
>
> There was no agreement on the best way to handle data with multiple
> modes, so we went with the simplest version that could work. It's easier
> to add functionality to the standard library than to take it away:
> better to delay putting something in for a release or two, than to put
> it in and then be stuck with the consequences of a poor decision for
> years.
>
> An earlier version of statistics.py included a mode function that let
> you specify the maximum number of modes. That function may eventually be
> added to the module, or made available on PyPI. The version included in
> the standard library implements the basic, school-book version of mode:
> it returns the one unique mode, as calculated by counting distinct
> values, or it fails, and the most Pythonic way to implement failure is
> with an exception.
>
[snip]

Data that has multiple modes is "multimodal" (who said stats was
difficult? :-)), so perhaps there could be a "multimode" function that
returns a list of modes.



More information about the Python-ideas mailing list