"""This object *store* a numerical population in a way that enables relatively
fast addition of new numbers (:math:`O(2log_2 n)`) and instant access to the
median value in the population (:math:`O(1)`). It also provides other population
- summary statistics such as the :meth:`mode`, :meth:`get_percentile` and
- :meth:`stdev`.
+ summary statistics such as the :meth:`get_mode`, :meth:`get_percentile` and
+ :meth:`get_stdev`.
.. note::
>>> pop.get_mean()
5.2
>>> round(pop.get_stdev(), 1)
- 1.4
+ 3.1
>>> pop.get_percentile(20)
3
>>> pop.get_percentile(60)
for n in self.highers:
variance += (n - mean) ** 2
count = len(self.lowers) + len(self.highers)
- return math.sqrt(variance) / count
+ return math.sqrt(variance / count)
def _create_sorted_copy_if_needed(self, count: int):
"""Internal helper."""
Args:
n: the float to truncate
+ decimals: how many decimal places are desired?
>>> truncate_float(3.1415927, 3)
3.141
return True
-if __name__ == '__main__':
+if __name__ == "__main__":
import doctest
doctest.testmod()