X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=math_utils.py;h=49ad407a58330144116c7d07976462a521f46d46;hb=3cd90acd08d5a95f5fb95b79c8bfddebbe099291;hp=156862a9c1b55eeec5515efef82f8f951d59b416;hpb=1ff5dde5b037f8da4c9d5a65e2d7ad2f6715ff60;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