diff options
| author | Scott Gasch <[email protected]> | 2022-02-11 11:14:20 -0800 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2022-02-11 11:14:20 -0800 |
| commit | 699219341e92365b7aa2f84df0c141bc4f0aa238 (patch) | |
| tree | 0510066639ad71d910e9067560f624bfdbce82dc | |
| parent | 2e8dd08f5f4f9624facf4d38ea6b276cc8131f56 (diff) | |
Fix stdev.
| -rw-r--r-- | math_utils.py | 5 |
1 files 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) |
