From: Scott Gasch Date: Fri, 11 Feb 2022 19:14:20 +0000 (-0800) Subject: Fix stdev. X-Git-Url: https://wannabe.guru.org/gitweb/?a=commitdiff_plain;h=699219341e92365b7aa2f84df0c141bc4f0aa238;p=python_utils.git Fix stdev. --- diff --git a/math_utils.py b/math_utils.py index 31610ba..3a672da 100644 --- a/math_utils.py +++ b/math_utils.py @@ -25,7 +25,7 @@ class NumericPopulation(object): >>> pop.get_mean() 5.2 >>> round(pop.get_stdev(), 2) - 6.99 + 1.75 >>> pop.get_percentile(20) 3 >>> pop.get_percentile(60) @@ -80,7 +80,8 @@ class NumericPopulation(object): variance += (n - mean) ** 2 for n in self.highers: variance += (n - mean) ** 2 - return math.sqrt(variance) + count = len(self.lowers) + len(self.highers) - 1 + return math.sqrt(variance) / count def get_percentile(self, n: float) -> float: """Returns the number at approximately pn% (i.e. the nth percentile)