Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:
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. ---------- components: +Library (Lib) versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40855> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com