[issue39094] Add a default to statistics.mean and related functions

Steven D'Aprano report at bugs.python.org
Thu Dec 19 06:21:33 EST 2019


Steven D'Aprano <steve+python at pearwood.info> added the comment:

TL;DR: I'm not likely to accept this feature request without at least one of (1) a practical use-case, (2) prior art in other statistics software, or (3) a strong mathematical justification for why this is meaningful and useful.


I'm not categorically against this idea, but it seems a bit fishy to me. If you have no data, how do you know what default value to give that would be appropriate for your (non-existent) observations?

It might help if you could show a real-life example of how, and why, you would use this, and how you would choose the default?

Another possibility would be to find prior-art: another language, library or stats calculator which already offers this feature.

Alternatively, a mathematical/statistical justification for a default. For example, the empty sum is normally taken as 0 and the empty product as 1. R returns either a NAN or NA for the empty mean (depending on precisely how you calculate it).

While I'm personally sympathetic to the nuisance factor of having to wrap code in try...except blocks (my *personal* preference would have been for mean to return NAN on empty input) I think you will need to make a stronger case than just the analogy with min and max.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39094>
_______________________________________


More information about the Python-bugs-list mailing list