Fix stdev.
authorScott Gasch <[email protected]>
Fri, 11 Feb 2022 19:14:20 +0000 (11:14 -0800)
committerScott Gasch <[email protected]>
Fri, 11 Feb 2022 19:14:20 +0000 (11:14 -0800)
math_utils.py

index 31610ba5fd2a0726b5b1f151dc87cc362b7389d4..3a672da1caf406d3a842ae46923a88063743dbbd 100644 (file)
@@ -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)