def testEmptyDataset(self): dataset = [] linReg = calculator.linearRegression(dataset) standardDeviation = calculator.standardDeviation(dataset, linReg) with self.assertRaises(Exception): (lowerInterval, higherInterval) = calculator.confidenceInterval(dataset, linReg, standardDeviation, self.confidence, self.estimation)
def testNormalCondition(self): dataset = [ (130, 186), (650, 699), (99, 132), (150, 272), (128, 291), (302, 331), (95, 199), (945, 1890), (368, 788), (961, 1601) ] linReg = calculator.linearRegression(dataset) standardDeviation = calculator.standardDeviation(dataset, linReg) (lowerInterval, higherInterval) = calculator.confidenceInterval(dataset, linReg, standardDeviation, self.confidence, self.estimation) self.assertEqual((lowerInterval, higherInterval), (1471.4585277625715, 2350.5491765845945))
def testAllZeroes(self): dataset = [ (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0) ] linReg = calculator.linearRegression(dataset) standardDeviation = calculator.standardDeviation(dataset, linReg) (lowerInterval, higherInterval) = calculator.confidenceInterval(dataset, linReg, standardDeviation, self.confidence, self.estimation) self.assertEqual((lowerInterval, higherInterval), (0, 0))
def testNormalStandardDeviation(self): dataset = [1, 10, 1, 10, 1 , 10] standardDeviation = calculator.standardDeviation(dataset) self.assertEqual(round(standardDeviation, 3), 4.93)
def testInvalidStandardDeviation(self): dataset = ['ok', 2, 3, 4, 5, 6] with self.assertRaises(Exception): standardDeviation = calculator.standardDeviation(dataset)
def testUpperBoundStandardDeviation(self): dataset = [MAX_VALUE, 0, 0] standardDeviation = calculator.standardDeviation(dataset) self.assertEqual(round(standardDeviation, 3), 1239850261.676)
def testLowerBoundStandardDeviation(self): dataset = [MIN_VALUE, MIN_VALUE, 0, 0, 10] standardDeviation = calculator.standardDeviation(dataset) self.assertEqual(standardDeviation, 1176225237.7088258)