def _calc_basic_statistics(self): """This function determines the mean and the standard deviation of the data sample. Furthermore, several other simple properties are determined. """ self.mean = stats.mean(self._data_samples) self.geom_mean = stats.geomean(self._data_samples) self.median = stats.median(self._data_samples) self.std_dev = stats.stddev(self._data_samples) self.min = min(self._data_samples) self.max = max(self._data_samples)
def test_stddev_simple(self): self.assertAlmostEqual(0.8164965809, stats.stddev([1, 2, 3])) self.assertAlmostEqual(0.8164965809, stats.stddev([1.0, 2.0, 3.0])) self.assertAlmostEqual(14.142135623, stats.stddev(self._integers)) self.assertAlmostEqual(14.142135623, stats.stddev(self._floats)) self.assertAlmostEqual(14.142135623, stats.stddev(self._floats2)) self.assertAlmostEqual(14.319929870, stats.stddev(self._mixed))
def test_stddev_vs_numpy(self): self.assertAlmostEqual(numpy.std([1, 2, 3]), stats.stddev([1, 2, 3])) self.assertAlmostEqual(numpy.std([1.0, 2.0, 3.0]), stats.stddev([1.0, 2.0, 3.0])) self.assertAlmostEqual(numpy.std(self._integers), stats.stddev(self._integers)) self.assertAlmostEqual(numpy.std(self._floats), stats.stddev(self._floats)) self.assertAlmostEqual(numpy.std(self._floats2), stats.stddev(self._floats2)) self.assertAlmostEqual(numpy.std(self._mixed), stats.stddev(self._mixed))