diff options
| author | Scott Gasch <[email protected]> | 2022-07-02 09:59:20 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2022-07-02 09:59:20 -0700 |
| commit | e4f0a5a96d6435166699cc1131f655c8904c1ddd (patch) | |
| tree | cf24f8e49f3c2782f7df4146911dc2d9a9d31767 | |
| parent | f6ec577f04044f21076c4c24c6aa2ab784c6cfc9 (diff) | |
Bugfixes in math_utils.
| -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 dd26cb6..64cd9fb 100644 --- a/math_utils.py +++ b/math_utils.py @@ -96,7 +96,7 @@ class NumericPopulation(object): variance += (n - mean) ** 2 for n in self.highers: variance += (n - mean) ** 2 - count = len(self.lowers) + len(self.highers) - 1 + count = len(self.lowers) + len(self.highers) return math.sqrt(variance) / count def _create_sorted_copy_if_needed(self, count: int): @@ -120,7 +120,8 @@ class NumericPopulation(object): self._create_sorted_copy_if_needed(count) assert self.sorted_copy index = round(count * (n / 100.0)) - assert 0 <= index < count + index = max(0, index) + index = min(count - 1, index) return self.sorted_copy[index] |
