Raymond Hettinger <[email protected]> added the comment:
The relevant code is in the _ss() helper function:
# The following sum should mathematically equal zero, but due to rounding
# error may not.
U, total2, count2 = _sum((x-c) for x in data)
assert T == U and count == count2
total -= total2**2/len(data)
The intent was to correct for small rounding errors, but the effect is to undo
any xbar value that differs from the true mean.
>From a user point-of-view the xbar parameter should have two effects, saving
>the computation time for the mean and also giving the ability to recenter the
>stdev/variance around a different point. It does save a call to mean;
>however, that effort is mostly throw-away by the rounding adjustment code
>which does even more work than computing the mean.
Likely, the fix for this is skip the rounding adjustment code if the user
supplies an xbar value.
----------
assignee: -> steven.daprano
nosy: +steven.daprano
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue40855>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com