X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=math_utils.py;fp=math_utils.py;h=49ad407a58330144116c7d07976462a521f46d46;hb=d2e437a04124fa3c6e3175205f943769ba443393;hp=156862a9c1b55eeec5515efef82f8f951d59b416;hpb=0dc52d000262da329728e01444242e35809e107e;p=python_utils.git diff --git a/math_utils.py b/math_utils.py index 156862a..49ad407 100644 --- a/math_utils.py +++ b/math_utils.py @@ -74,6 +74,8 @@ class NumericPopulation(object): return self.aggregate / count def get_mode(self) -> Tuple[float, int]: + """Returns the mode (most common member).""" + count: Dict[float, int] = collections.defaultdict(int) for n in self.lowers: count[-n] += 1