[issue18606] Add statistics module to standard library

Mark Dickinson report at bugs.python.org
Tue Aug 20 14:43:28 CEST 2013


Mark Dickinson added the comment:

I agree with Oscar about sum for decimal.Decimal.  The *ideal* sum for Decimal instances would return the correctly rounded result (i.e., the exact result, rounded to the current context just once using the current rounding mode).  It seems wrong to give a guarantee of behaviour that's in conflict with this ideal.

IEEE 754 recommends a 'sum' operation (in section 9.4, amongst other reduction operations), but doesn't go so far as to either require or recommend that the result be correctly rounded.  Instead, it says "Implementations may associate in any order or evaluate in any wider format.", and then later on, "Numerical results [...] may differ among implementations due to the precision of intermediates and the order of evaluation."  It certainly *doesn't* specify that the results should be as though the context precision and rounding mode were used for every individual addition.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18606>
_______________________________________


More information about the Python-bugs-list mailing list