def proportion(data): p = len(data) height = 0 for values in data: if height > 64: addition(height) return division(values, p)
def sample_st_dev(data): mean = sampleMean(data) sample_data = data[0:999] tot = 0.0 for x in sample_data: tot = addition(tot, (x - mean)**2) return round((tot / (len(sample_data) - 1))**0.5, 2)
def sampleMean(data, sample_size): total = 0 sample = sampleData(data, sample_size) sample_values = len(sample) for value in sample: total = addition(total, value) return division(total, sample_values)
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 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 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 add(self, a, b): self.result = addition(float(a), float(b)) return self.result
def population_mean(data): n = len(data) total = 0 for item in data: total = addition(total, item) return division(total, n)