The stdev calculation is more accurate computing its own mean (#92220)

This commit is contained in:
Raymond Hettinger 2022-05-03 03:41:46 -05:00 committed by GitHub
parent 9b027d4cea
commit ec8d3adb99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 2 deletions

View 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."