def export_normal_distribution(self, column, date): path = DataFrame.get_export_path(date) mean = MathsUtil.arr_mean(self.data[self.headers[column]]) median = MathsUtil.arr_median(self.data[self.headers[column]]) mode = MathsUtil.arr_mode(self.data[self.headers[column]]) GraphUtils.export_distribution_graph(self.data[self.headers[column]], self.headers[column], mean, median, mode, path) print(f"exported {path}dist_{self.headers[column]}")
def plot_normal_distribution(self, column): mean = MathsUtil.arr_mean(self.data[self.headers[column]]) median = MathsUtil.arr_median(self.data[self.headers[column]]) mode = MathsUtil.arr_mode(self.data[self.headers[column]]) GraphUtils.show_distribution_graph(self.data[self.headers[column]], self.headers[column], mean, median, mode)
def print_deviation_calculations(self, column): rows = self.data[self.headers[column]] DataFrame.print_deviation_calculation("Mean", rows, MathsUtil.arr_mean(rows)) DataFrame.print_deviation_calculation("Median", rows, MathsUtil.arr_median(rows)) DataFrame.print_deviation_calculation("Mode", rows, MathsUtil.arr_mode(rows))
def test_arr_standard_deviation(self): self.assertEqual(MathsUtil.arr_standard_deviation([3, 9], MathsUtil.arr_mean([3, 9])), 3)
def test_arr_variance(self): self.assertEqual(MathsUtil.arr_variance([1, 2, 3, 4], MathsUtil.arr_mean([1, 2, 3, 4])), 1.25) self.assertEqual(MathsUtil.arr_variance([-10, 1, 2, 3, 4], MathsUtil.arr_mean([-10, 1, 2, 3, 4])), 26)
def test_mean_of_array(self): self.assertEqual(MathsUtil.arr_mean([1, 2, 3]), 2) self.assertEqual(MathsUtil.arr_mean([14, -2, -3]), 3) self.assertEqual(MathsUtil.arr_mean([1, 2.6, 3.07, 2.3524]), 2.2556)