[Python-ideas] Discuss: what should statistics.mode do?

Steven D'Aprano steve at pearwood.info
Mon Feb 18 19:16:23 EST 2019


See https://bugs.python.org/issue35892

The issue here is that statistics.mode, as initially designed, raises an 
exception for the case of multiple equal most-frequent data points. This 
is true to the way mode is taught in schools, but it may not be the most 
useful behaviour.

Raymond has suggested:

- keep the status quo;

- change mode() to return "the first tie" instead of raising an 
  exception (with or without a deprecation warning for one release);

- add a flag to specify the behaviour.


I'm especially interested in opinions from those who use the 
function. What would be useful for you? How do you use it?
interactively or in scripts?

(When I designed this, I mostly imagined that mode() would be used 
interactively, using the interpreter as a calculator.)

Would changing the behaviour break your code?

Note that this question is seperate from that of whether or not there 
should be a multimode function.


-- 
Steven


More information about the Python-ideas mailing list