Message370684
Perhaps this would work:
diff --git a/Lib/statistics.py b/Lib/statistics.py
index c76a6ca519..93a4633464 100644
--- a/Lib/statistics.py
+++ b/Lib/statistics.py
@@ -682,8 +682,10 @@ def _ss(data, c=None):
calculated from ``c`` as given. Use the second case with care, as it can
lead to garbage results.
"""
- if c is None:
- c = mean(data)
+ if c is not None:
+ T, total, count = _sum((x-c)**2 for x in data)
+ return (T, total)
+ c = mean(data)
T, total, count = _sum((x-c)**2 for x in data)
# The following sum should mathematically equal zero, but due to rounding
# error may not.
Matti, where do you get 0.5 as the expected outcome for the third example? The actual mean is 1.5, so I would expect the third case to give sqrt(2)/2 or 0.707. |
|
Date |
User |
Action |
Args |
2020-06-03 20:17:43 | rhettinger | set | recipients:
+ rhettinger, steven.daprano, Folket |
2020-06-03 20:17:43 | rhettinger | set | messageid: <1591215463.05.0.111872612812.issue40855@roundup.psfhosted.org> |
2020-06-03 20:17:42 | rhettinger | link | issue40855 messages |
2020-06-03 20:17:42 | rhettinger | create | |
|