projects
/
python_utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a4b50bb
)
Fix a bug, add some testcases.
author
Scott Gasch
<
[email protected]
>
Thu, 10 Feb 2022 16:47:45 +0000
(08:47 -0800)
committer
Scott Gasch
<
[email protected]
>
Thu, 10 Feb 2022 16:47:45 +0000
(08:47 -0800)
math_utils.py
patch
|
blob
|
history
diff --git
a/math_utils.py
b/math_utils.py
index 28b8e6b3b6d9a407c6f263220e314d9d4acacbc0..f77e0a1f2514f5a0201c81f57e9740d36d2ede47 100644
(file)
--- a/
math_utils.py
+++ b/
math_utils.py
@@
-21,6
+21,10
@@
class RunningMedian(object):
>>> median.add_number(5)
>>> median.get_median()
5
+ >>> median.get_mean()
+ 5.2
+ >>> round(median.get_stdev(), 2)
+ 6.99
"""
def __init__(self):
@@
-57,6
+61,7
@@
class RunningMedian(object):
mean = self.get_mean()
variance = 0.0
for n in self.lowers:
+ n = -n
variance += (n - mean) ** 2
for n in self.highers:
variance += (n - mean) ** 2