def Pop_correlation_coefficient(): lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] x_data = [1, 25, 34, 4, 51] y_data = [6, 7, 8, 9, 10] x_mean = mean(x_data) y_mean = mean(y_data) a = [] b = [] ab = [] x = st_dev(x_data) y = st_dev(y_data) divisor = multiplication(x, y) z = len(lst) for i in x_data: new1 = subtraction(x_mean, i) zx = division(new1, x) a.append(zx) # (zx)i = (xi – x̄) / s x for i in y_data: new2 = subtraction(y_mean, i) zy = division(new2, y) b.append(zy) ab = [a[i] * b[i] for i in range(len(x_data))] tot_sum = sum(ab) result = tot_sum / 4 return result
def Pop_correlation_coefficient(x_data, y_data): x_mean = mean(x_data) y_mean = mean(y_data) a = [] b = [] tot_sum = 0 x = st_dev(x_data) y = st_dev(y_data) for i in x_data: new1 = subtraction(x_mean, i) zx = division(new1, x) a.append(zx) for i in y_data: new2 = subtraction(y_mean, i) zy = division(new2, y) b.append(zy) for i in range(len(x_data)): ab = multiplication(a[i], b[i]) tot_sum = addition(tot_sum, ab) cal_result = division(tot_sum, subtraction(1, len(x_data))) return cal_result
def confidenceinterval(lst, conf): x = mean(lst) std = st_dev(lst) if conf == 95: t = 1.96 elif conf == 90: t = 1.64 elif conf == 99: t = 2.58 else: # 95 default confidence percentage t = 1.96 std_error = division(std, root(len(lst))) conf_upper = addition(x, multiplication(t, std_error)) conf_upper = round(conf_upper, 2) conf_lower = subtraction(multiplication(t, std_error), x) conf_lower = round(conf_lower, 2) return conf_upper, conf_lower
def zscore(lst): m = mean(lst) s = st_dev(lst) for z in lst: return division(subtraction(m, z), s)
def stddev(self, a): self.result = st_dev(a) return self.result
def pop_variance(lst): s = st_dev(lst) return square(s)
def zscore(lst): raw_value = 16 m = mean(lst) s = st_dev(lst) return division(subtraction(m, raw_value), s)