summaryrefslogtreecommitdiffstats
path: root/Lib/statistics.py
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2020-06-13 22:55:52 (GMT)
committerGitHub <noreply@github.com>2020-06-13 22:55:52 (GMT)
commitd71ab4f73887a6e2b380ddbbfe35b600d236fd4a (patch)
treedb2209b54126a1f9e476c176105153733ae933c1 /Lib/statistics.py
parentdea3223740127ac13f984c1d38f127ab6701af44 (diff)
downloadcpython-d71ab4f73887a6e2b380ddbbfe35b600d236fd4a.zip
cpython-d71ab4f73887a6e2b380ddbbfe35b600d236fd4a.tar.gz
cpython-d71ab4f73887a6e2b380ddbbfe35b600d236fd4a.tar.bz2
bpo-40855: Fix ignored mu and xbar parameters (GH-20835)
Diffstat (limited to 'Lib/statistics.py')
-rw-r--r--Lib/statistics.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/statistics.py b/Lib/statistics.py
index c76a6ca..93a4633 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.