Пример #1
0
def z_score_list(data):
    if is_valid(data):
        tmp = []
        u = mean(data)
        s = standard_deviation(data)
        for x in data:
            tmp.append(z_score(x, u, s))
        return tmp
    else:
        raise TypeError("Data contains non-numeric values")
Пример #2
0
def variance(data):
    if is_valid(data):
        size = len(data)
        x = mean(data)
        tmp = []
        for i in data:
            diff = subtract(i, x)
            tmp.append(square(diff))
        total = add_list(tmp)
        return divide(total, size)
    else:
        raise TypeError("Data contains non-numeric values")
Пример #3
0
def standard_deviation(data):
    if is_valid(data):
        var = variance(data)
        return get_square_root(var)
    else:
        raise TypeError("Data contains non-numeric values")
Пример #4
0
 def mode(self, data):
     if is_valid(data):
         self.result = mode(data)
         return self.result
     else:
         raise TypeError("Data contains non-numeric values")