def test_correlationcoefficient_for_perfect_positive_is_one(self): res = of.correlationcoefficient(self.evaluation, self.evaluation) self.assertAlmostEqual(res, 1, self.tolerance) res = of.correlationcoefficient(self.evaluation, 2*self.evaluation) self.assertAlmostEqual(res, 1, self.tolerance) res = of.correlationcoefficient(self.evaluation, 0.5*self.evaluation) self.assertAlmostEqual(res, 1, self.tolerance)
def test_correlationcoefficient_for_perfect_negative_is_minus_one(self): res = of.correlationcoefficient(self.evaluation, -self.evaluation) self.assertAlmostEqual(res, -1, self.tolerance) res = of.correlationcoefficient(self.evaluation, -2*self.evaluation) self.assertAlmostEqual(res, -1, self.tolerance) res = of.correlationcoefficient(self.evaluation, -0.5*self.evaluation) self.assertAlmostEqual(res, -1, self.tolerance)
def test_correlationcoefficient_random(self): res = of.correlationcoefficient(self.evaluation, self.simulation) self.assertAlmostEqual(res, -0.110510977276, self.tolerance)