def test_setListOfVals_return_None(self): listOfVals = [0, 2, 4, 6, 8, 10] newList = [1, 3, 5, 7, 9] stats = Statistics(listOfVals) stats.setListOfVals(newList) actual = stats.getList() expected = [1, 3, 5, 7, 9] self.assertEqual(actual, expected)
def testZScorelistReturnList(self): list = [1, 2, 3, 4, 5] stat = Statistics(list) actual = stat.zscore() expected = { 1: -1.414213562373095, 2: -0.7071067811865475, 3: 0.0, 4: 0.7071067811865475, 5: 1.414213562373095 } self.assertEqual(expected, actual)
def testnegativeCorrelationCoefficientReturnsRvalue(self): list = [-1, -2, -3, -4, -5] stat = Statistics(list) expected = -0.9999999999999998 actual = stat.correlationCoefficient() self.assertEqual(expected, actual)
def testpopulationstandarddeviation_returns_std(self): list = [1, 2, 3, 4, 5] stat = Statistics(list) actual = stat.standardDeviation() expected = 1.4142135623730951 self.assertEqual(expected, actual)
def testcorrelationCoefficientReturnsRvalue(self): list = [1, 2, 3, 4, 5] stat = Statistics(list) expected = 0.9999999999999998 actual = stat.correlationCoefficient() self.assertEqual(expected, actual)
def testChebyshevInequalityreturnNone(self): emptyList = [] stat = Statistics(emptyList) actual = stat.chebyshevInequality() expected = None self.assertEqual(expected, actual)
def test_arthmeticMean_return_3(self): list = [1, 2, 3, 4, 5] stat = Statistics(list) actual = stat.arithmeticMean() expected = 3 self.assertEqual(actual, expected)
def testLargeDataSetCorrelationCoefficientReturnsRvalue(self): list = [1, 2, 1, 2, 5, 2, 4, 6, 7, 9, 0, 2, 3, 4, 5, 7, 6] stat = Statistics(list) expected = 0.4665694748158436 actual = stat.correlationCoefficient() self.assertEqual(expected, actual)
def test_medianOddList_return_3(self): oddList = [1, 2, 3, 4, 5] stat = Statistics(oddList) actual = stat.median() expected = 3 self.assertEqual(expected, actual)
def testPlotDataMeanLargeDataSetReturnGraph(self): list = [] for i in range(0, 99): list.append(random.randint(0, 99)) stat = Statistics(list) stat.plotDataMean()
def testZScoreEmptyListReturnNone(self): emptylist = [] stat = Statistics(emptylist) actual = stat.zscore() expected = None self.assertEqual(expected, actual)
def testPlotDataReturnGraph(self): list = [1, 2, 3, 4, 5] stat = Statistics(list) stat.plotData()
def testPlotDataMeanEmptyDataSetReturnGraph(self): emptylist = [] stat = Statistics(emptylist) stat.plotDataMean()
def testPlotDataReturnEmptyGraph(self): emptyList = [] stat = Statistics(emptyList) stat.plotData()
def test_rangeList_return_none(self): emptyList = [] stat = Statistics(emptyList) actual = stat.rangeList() expected = None self.assertEqual(actual, expected)
def testChebyshevInequalityreturnCI(self): list = [1, 2, 3, 4, 5] stat = Statistics(list) actual = stat.chebyshevInequality() expected = 0.5000000000000001 self.assertEqual(expected, actual)
def testsameDataSetCorrelationCoefficientReturnsRvalue(self): list = [1, 2, 1, 2, 1] stat = Statistics(list) expected = 0 actual = stat.correlationCoefficient() self.assertEqual(expected, actual)
def testZScoreOneValuelistReturnList(self): list = [1] stat = Statistics(list) actual = stat.zscore() expected = {1: 0} self.assertEqual(expected, actual)
def testoneOffCorrelationCoefficientReturnsRvalue(self): list = [1, 2, 1, 2, 5] stat = Statistics(list) expected = 0.7698003589195009 actual = stat.correlationCoefficient() self.assertEqual(expected, actual)
def test_negativeMin_rangeList_return_range(self): listOfVal = [-1, 2, 3, 4, 5] stat = Statistics(listOfVal) actual = stat.rangeList() expected = 6 self.assertEqual(actual, expected)
def test_medianEmtpyList_return_none(self): emptyList = [] stat = Statistics(emptyList) actual = stat.median() expected = None self.assertEqual(expected, actual)
def test_getListOfVals_returns_List(self): listOfVals = [0, 2, 4, 6, 8, 10] stats = Statistics(listOfVals) actual = stats.getList() expected = [0, 2, 4, 6, 8, 10] self.assertEqual(actual, expected)
def test_medianEvenList_return_2_5(self): evenList = [1, 2, 3, 4] stat = Statistics(evenList) actual = stat.median() expected = 2.5 self.assertEqual(expected, actual)
def testsamplestandarddeviation_returns_std(self): list = [1, 2, 3, 4, 5] stat = Statistics(list) actual = stat.standardDeviation(population=False) expected = 1.5811388300841898 self.assertEqual(actual, expected)
def test_negativeMinMax_rangeList_return_range(self): listOfVal = [-1, -2, -3, -4, -5] stat = Statistics(listOfVal) actual = stat.rangeList() expected = 4 self.assertEqual(actual, expected)
def testZScoreSameValuelistReturnList(self): list = [1, 1, 1, 1, 1] stat = Statistics(list) actual = stat.zscore() expected = None self.assertEqual(expected, actual)
def test__rangeListsameInterval_return_range(self): listOfVal = [1, 1, 1] stat = Statistics(listOfVal) actual = stat.rangeList() expected = 0 self.assertEqual(actual, expected)
def testcorrelationCoefficientReturnsNone(self): emptyList = [] stat = Statistics(emptyList) expected = None actual = stat.correlationCoefficient() self.assertEqual(expected, actual)
def test_arithmeticMean_return_1(self): list = [1, 1, 1] stat = Statistics(list) actual = stat.arithmeticMean() expected = 1 self.assertEqual(actual, expected)
def testcorrelationCoefficientReturnsZero(self): list = [1] stat = Statistics(list) expected = 0 actual = stat.correlationCoefficient() self.assertEqual(expected, actual)