]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
The stdev calculation is more accurate computing its own mean (#92220)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Tue, 3 May 2022 08:41:46 +0000 (03:41 -0500)
committerGitHub <noreply@github.com>
Tue, 3 May 2022 08:41:46 +0000 (03:41 -0500)
Lib/statistics.py

index f3bc9a1f346397ac5a230c949fa55ea2b439e3c6..6e6d62c4a0e2639e38ecf617452ec9505af5cef7 100644 (file)
@@ -1173,8 +1173,7 @@ class NormalDist:
         "Make a normal distribution instance from sample data."
         if not isinstance(data, (list, tuple)):
             data = list(data)
-        xbar = fmean(data)
-        return cls(xbar, stdev(data, xbar))
+        return cls(mean(data), stdev(data))
 
     def samples(self, n, *, seed=None):
         "Generate *n* samples for a given mean and standard deviation."