From 699219341e92365b7aa2f84df0c141bc4f0aa238 Mon Sep 17 00:00:00 2001 From: Scott Gasch Date: Fri, 11 Feb 2022 11:14:20 -0800 Subject: [PATCH] Fix stdev. --- math_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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) -- 2.45.2