Message370680
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. |
|
Date |
User |
Action |
Args |
2020-06-03 16:45:19 | rhettinger | set | recipients:
+ rhettinger, steven.daprano, Folket |
2020-06-03 16:45:19 | rhettinger | set | messageid: <1591202719.5.0.748119098476.issue40855@roundup.psfhosted.org> |
2020-06-03 16:45:19 | rhettinger | link | issue40855 messages |
2020-06-03 16:45:19 | rhettinger | create | |
|