Update docs.
[pyutils.git] / src / pyutils / math_utils.py
index 40c6df982c6013afe767d0ff1cff6006337e749c..dd8f33a2e4bf781b658d4ae7266e4a3035412dbb 100644 (file)
@@ -17,8 +17,8 @@ class NumericPopulation(object):
     """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::
 
@@ -40,7 +40,7 @@ class NumericPopulation(object):
     >>> pop.get_mean()
     5.2
     >>> round(pop.get_stdev(), 1)
-    1.4
+    3.1
     >>> pop.get_percentile(20)
     3
     >>> pop.get_percentile(60)
@@ -138,7 +138,7 @@ class NumericPopulation(object):
         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."""
@@ -218,6 +218,7 @@ def truncate_float(n: float, decimals: int = 2):
 
     Args:
         n: the float to truncate
+        decimals: how many decimal places are desired?
 
     >>> truncate_float(3.1415927, 3)
     3.141
@@ -314,7 +315,7 @@ def is_prime(n: int) -> bool:
     return True
 
 
-if __name__ == '__main__':
+if __name__ == "__main__":
     import doctest
 
     doctest.testmod()