def var_sample_proportion(data, sample_size): height = 0 sample = sampleData(data, sample_size) sample_values = len(sample) x = proportion(data) z = subtraction(1, x) y = subtraction(sample_values, 1) for height_el in sample: height = multiplication(x, z) return division(height, y)
def sample_st_dev(data, sample_size): dev = 0 sample = sampleData(data, sample_size) sample_values = len(sample) x_bar = sampleMean() x = sample_values n = subtraction(sample_values, 1) for dev in sample: dev = subtraction(x, x_bar) square_x_bar = square(dev) add = addition(square_x_bar, square_x_bar) divide = division(add, n) return square_root(divide)
def var_pop_proportion(data): p = proportion(data) q = subtraction(1, p) data = [num for elem in data for num in elem] new_data = [float(x) for x in data] n = len(new_data) return division(n, multiplication(p, q))
def z_score(data): u = population_mean(data) new_data = [float(x) for x in data] x = new_data[1] pop_sd = pop_stand_dev(new_data) y = subtraction(x, u) z = division(pop_sd, y) return z
def z_score(data): data = [num for elem in data for num in elem] new_data = [float(x) for x in data] x = new_data[1] u = population_mean(new_data) sample_sd = sample_st_dev(new_data) y = subtraction(x, u) return division(sample_sd, y)
def population_variance(data): u = population_mean(data) deviations = subtraction(data, u) sq_deviations = square(deviations) x = len(data) y = sum(sq_deviations) d = division(x, y) return d
def population_variance(data): data = [num for elem in data for num in elem] new_data = [float(x) for x in data] u = population_mean(new_data) deviations = subtraction(new_data, u) sq_deviations = square(deviations) x = len(new_data) y = sum(sq_deviations) d = division(x, y) return d
def confidence_interval(data): # For a Confidence Interval of 95% z_value = 1.960 mean = sampleMean(data) sd = pop_stand_dev(data) x = len(data) y = division(square_root(x), sd) margin_of_error = multiplication(z_value, y) a = subtraction(mean, margin_of_error) b = addition(mean, margin_of_error) return a, b
def var_sample_proportion(data): sample_data = data[0:999] samp_prop_data = [] for x in sample_data: if x > 64: samp_prop_data.append(x) samp_len = len(samp_prop_data) samp_len_data = len(sample_data) p = round(samp_len / samp_len_data, 6) q = subtraction(1, p) return round(multiplication(p, q) / (samp_len_data - 1), 6)
def confidence_interval(data): data = [num for elem in data for num in elem] new_data = [float(x) for x in data] # For a Confidence Interval of 95% z_value = 1.960 mean = sampleMean(new_data) sd = pop_stand_dev(new_data) x = len(new_data) y = division(square_root(x), sd) margin_of_error = multiplication(z_value, y) a = subtraction(mean, margin_of_error) b = addition(mean, margin_of_error) return a, b
def confidence_interval(data): # For a Confidence Interval of 95% z_value = 1.960 mean = population_mean(data) sd = pop_stand_dev(data) x = len(data) y = division(square_root(x), sd) margin_of_error = multiplication(z_value, y) a = [subtraction(mean, margin_of_error)] b = [addition(mean, margin_of_error)] size = len(a) # c = [(a[i], b[i]) for i in range(size)] lower = a[0] upper = b[0] # print(lower, upper) return lower, upper
def z_score(data): x = 64 u = population_mean(data) sample_sd = sample_st_dev(data) y = subtraction(x, u) return division(sample_sd, y)
def var_pop_proportion(data): p = proportion(data) q = subtraction(p, 1) n = len(data) return division(multiplication(p, q), n)
def subtract(self, a, b): self.result = subtraction(float(a), float(b)) return self.result