projects
/
python_utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bugfixes in math_utils.
[python_utils.git]
/
math_utils.py
diff --git
a/math_utils.py
b/math_utils.py
index dd26cb6f175dea80ae28181c9cf983115b37f323..64cd9fb65839503b72baf5d3f95adbeb5a441101 100644
(file)
--- 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
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):
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))
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]
return self.sorted_copy[index]