mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
The stdev calculation is more accurate computing its own mean (#92220)
This commit is contained in:
parent
9b027d4cea
commit
ec8d3adb99
1 changed files with 1 additions and 2 deletions
|
@ -1173,8 +1173,7 @@ class NormalDist:
|
||||||
"Make a normal distribution instance from sample data."
|
"Make a normal distribution instance from sample data."
|
||||||
if not isinstance(data, (list, tuple)):
|
if not isinstance(data, (list, tuple)):
|
||||||
data = list(data)
|
data = list(data)
|
||||||
xbar = fmean(data)
|
return cls(mean(data), stdev(data))
|
||||||
return cls(xbar, stdev(data, xbar))
|
|
||||||
|
|
||||||
def samples(self, n, *, seed=None):
|
def samples(self, n, *, seed=None):
|
||||||
"Generate *n* samples for a given mean and standard deviation."
|
"Generate *n* samples for a given mean and standard deviation."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue