X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=src%2Fpyutils%2Fmath_utils.py;h=10a9fb774b6f4bea5810f439774184398a33ccb3;hb=91334e2f21a891c38c4c9432c96f52132bafa801;hp=6f042907d47764d34c2b83d3def98f41080058e8;hpb=eb7d4fcb7edb2f6d405cbfbba6bb2df484af4d94;p=pyutils.git diff --git a/src/pyutils/math_utils.py b/src/pyutils/math_utils.py index 6f04290..10a9fb7 100644 --- a/src/pyutils/math_utils.py +++ b/src/pyutils/math_utils.py @@ -77,7 +77,7 @@ class NumericPopulation(object): heappush(self.lowers, -heappop(self.highers)) def get_median(self) -> float: - """Returns the approximate median (p50) so far in O(1) time.""" + """Returns the approximate median (p50) so far in :math:`O(1)` time.""" if len(self.lowers) == len(self.highers): return -self.lowers[0] @@ -87,14 +87,14 @@ class NumericPopulation(object): return self.highers[0] def get_mean(self) -> float: - """Returns the mean (arithmetic mean) so far in O(1) time.""" + """Returns the mean (arithmetic mean) so far in :math:`O(1)` time.""" count = len(self) return self.aggregate / count def get_mode(self) -> Tuple[float, int]: """Returns the mode (most common member in the population) - in O(n) time.""" + in :math:`O(n)` time.""" count: Dict[float, int] = collections.defaultdict(int) for n in self.lowers: @@ -104,7 +104,7 @@ class NumericPopulation(object): return dict_utils.item_with_max_value(count) def get_stdev(self) -> float: - """Returns the stdev so far in O(n) time.""" + """Returns the stdev so far in :math:`O(n)` time.""" mean = self.get_mean() variance = 0.0 @@ -127,7 +127,7 @@ class NumericPopulation(object): def get_percentile(self, n: float) -> float: """Returns the number at approximately pn% (i.e. the nth percentile) - of the distribution in O(n log n) time. Not thread-safe; + of the distribution in :math:`O(n log_2 n)` time. Not thread-safe; does caching across multiple calls without an invocation to add_number for perf reasons. """