This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients Folket, rhettinger, steven.daprano
Date 2020-06-03.20:17:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1591215463.05.0.111872612812.issue40855@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-06-03 20:17:43rhettingersetrecipients: + rhettinger, steven.daprano, Folket
2020-06-03 20:17:43rhettingersetmessageid: <1591215463.05.0.111872612812.issue40855@roundup.psfhosted.org>
2020-06-03 20:17:42rhettingerlinkissue40855 messages
2020-06-03 20:17:42rhettingercreate