Beispiel #1
0
def conf_inter(x, cl, s, n):
    var_1 = n - 1
    var_2 = subtract(1, cl)
    var_3 = divide(var_2, 2)
    var_4 = get_t_score(float(var_1), float(var_3))
    var_5 = get_square_root(n)
    var_6 = divide(s, var_5)
    var_7 = multiply(float(var_4), var_6)
    low = subtract(x, var_7)
    high = add(x, var_7)
    return [low, high]
Beispiel #2
0
def s_variance(data):
    if is_valid(data):
        size = len(data)
        n = subtract(size, 1)
        x = mean(data)
        tmp = []
        for i in data:
            diff = subtract(i, x)
            tmp.append(square(diff))
        total = add_list(tmp)
        return divide(total, n)
    else:
        raise TypeError("Data contains non-numeric values")
Beispiel #3
0
def sample_size_ci(z, p, w):
    var_1 = divide(z, 2)
    z_score = get_z_score(var_1)
    e = divide(w, 2)
    q = subtract(1, p)
    var_2 = multiply(p, q)
    var_3 = divide(float(z_score), e)
    var_5 = square(var_3)
    return multiply(var_2, var_5)
def median(num):
    try:
        num_values = len(num)
        list_num = [num[i] for i in range(num_values)]
        list_num.sort()
        if num_values % 2 == 0:
            median1 = list_num[int(num_values // 2)]
            median2 = list_num[int(subtract((num_values // 2), 1))]
            median_result = division(addition(median1, median2), 2)
        else:
            median_result = list_num[int(division(num_values, 2))]
        return median_result
    except ZeroDivisionError:
        print("Error: Can't Divide by 0")
    except ValueError:
        print("Error: Check your data inputs")
 def subtract(self, a, b):
     self.result = subtract(a, b)
     return self.result
Beispiel #6
0
def z_score(x, u, s):
    var_1 = subtract(x, u)
    return divide(var_1, s)