summaryrefslogtreecommitdiff
path: root/math_utils.py
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2022-02-10 08:47:45 -0800
committerScott Gasch <[email protected]>2022-02-10 08:47:45 -0800
commitd7d135be2f9dbb2d8398d7258f8bac24b4205a2b (patch)
treed88c433738b7abcdb77725a2353596bcb0741156 /math_utils.py
parenta4b50bb62e2653d3d084c6c7e0574abb9277b8d7 (diff)
Fix a bug, add some testcases.
Diffstat (limited to 'math_utils.py')
-rw-r--r--math_utils.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/math_utils.py b/math_utils.py
index 28b8e6b..f77e0a1 100644
--- 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