def correlation(x, y):
     if(len(x) == len(y)):
         n = len(x)
         sum_x = float(Addition.sumList(x))
         sum_y = float(Addition.sumList(y))
         sum_x_sq = sum(map(lambda x: pow(x, 2), x))
         sum_y_sq = sum(map(lambda x: pow(x, 2), y))
         psum = sum(imap(lambda x, y: x * y, x, y))
         num = psum - (sum_x * sum_y / n)
         den = pow((sum_x_sq - pow(sum_x, 2) / n) * (sum_y_sq - pow(sum_y, 2) / n), 0.5)
         if den == 0: return 0
         return num / den
     else:
         return -1
    def deviation_Calculator(data):
        newdata = []
        data.sort()
        n = len(data)
        mean = Mean.Mean_Calculator(data)
        for i in data:
            newdata.append(Exponentiation.power((i - mean),2))

        sum = Addition.sumList(newdata)
        return nthRoot.rooting(2,Division.divide(sum,n))
Esempio n. 3
0
    def stardardDev(data):
        n = len(data)
        mn = Mean.mean(data)
        newlist = []

        for i in data:
            newlist.append(Exponentiation.power(i - mn, 2))

        total = Addition.sumList(newlist)
        return nthroot.root(2, Division.divide(total, n))
Esempio n. 4
0
    def meanDev(data):

        newlist = []
        meanOfData = Mean.mean(data)

        for i in data:
            newlist.append(abs(i - meanOfData))

        total = Addition.sumList(newlist)
        return Division.divide(total, len(data))
Esempio n. 5
0
 def add(self, a, b):
     self.Result = Addition.sum(a, b)
     return self.Result
 def test_MathOperations_Add(self):
     result = Addition.sum(1, 2)
     self.assertEquals(3, result)
 def test_MathOperations_sum_list(self):
     valueList = [1, 2, 3]
     self.assertEqual(6, Addition.sum(valueList))
Esempio n. 8
0
 def test_MathOperations_Addition(self):
     self.assertEqual(3, Addition.sum(1, 2))
Esempio n. 9
0
 def mean(data):
     num_values = len(data)
     total = 0
     for num in data:
         total = Addition.sum(total, num)
     return Division.divide(total, num_values)
Esempio n. 10
0
 def Mean_Calculator(data):
     num = len(data)
     count = Addition.sumList(data)
     return Division.divide(count, num)
 def test_MO_sum_list(self):
     valuelist = [1, 2, 3]
     self.assertEqual(6, Addition.sum(valuelist))
 def test_MO_add(self):
     self.assertEqual(3, Addition.sum(1, 2))
Esempio n. 13
0
 def test_MathOperations_AdditionList(self):
     numberlist = [1, 2, 3]
     self.assertEqual(6, Addition.sumlist(numberlist))
Esempio n. 14
0
 def mean(data):
     num = len(data)
     total = Addition.sumList(data)
     return Division.divide(total, num)