def testOnTuples(self): "Checks that methods also work on tuples." self.assertAlmostEqual(basic.mean(tuple(self.dataA)), self.meanA, 5) self.assertAlmostEqual(basic.mean(tuple(self.dataB)), self.meanB, 5) self.assertAlmostEqual(basic.stddev(tuple(self.dataA)), self.stddevA, 5) self.assertAlmostEqual(basic.stddev(tuple(self.dataB)), self.stddevB, 5)
from basic import mean, median, mode _ = int(input()) arr = sorted(map(int, input().split())) print(mean(arr)) print(median(arr)) print(mode(arr))
def testBasicStats(self): "Test that the basic stats method works." meanA, stddevA = basic.basic_stats(self.dataA) self.assertAlmostEqual(meanA, basic.mean(self.dataA)) self.assertAlmostEqual(stddevA, basic.stddev(self.dataA))
def testMean(self): "Check that mean works as expected." self.assertAlmostEqual(basic.mean(self.dataA), self.meanA, 5) self.assertAlmostEqual(basic.mean(self.dataB), self.meanB, 5)
def least_squares(x, y): beta = correlation(x, y) * standart_deviation(y) / standart_deviation(x) alpha = mean(y) - beta * mean(x) return alpha, beta