import sys from random import randint from modules.econ_statistics import Econ_Statistics # Simple application to calculate sample data of a population # Intended to show difference between population and sample and to # show how the average of the [sample variance] approaches 0 as # repetitions increase data_list = [25, 24, 21, 23, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 19, 21, 20, 20, 21, 21, 20, 20, 19, 18, 19, 19, 22, 25, 21, 20, 28, 22, 20, 20, 20, 21, 24] ec = Econ_Statistics() print("Population average: {}".format(ec.get_average(data_list))) print("Population variance: {}".format(ec.get_variance(data_list))) looped = 0 while 1: slist = [] slist_avg = [] slist_var = [] try: ip = "y" if looped == 1 else raw_input("Would you like to sample the current list?\n> y - Yes\n> c - clear data\n> d - Display list\n> ") if ip.lower() == "y": while 1: if len(data_list) == 0: while 1: try: inp = raw_input("Add a number to the list:\n> d - Done\n> ") if inp == "d": break
data_list = [] print("Cleared data_list") else: try: data_list.append(int(number)) except: print("Incorrect input provided.") data_list.sort() print("Your number list: " + str(data_list)) print("Length of list: " + str(len(data_list))) print("Mean: " + str(ec.get_average(data_list))) print("Median: " + str(ec.get_median(data_list))) data_variance = ec.get_variance(data_list) print("Variance: "+ str(data_variance)) data_stdv = int(math.sqrt(data_variance)*10000)/10000 print("Standard Deviation: " + str(data_stdv)) print("Range: " + str(data_list[len(data_list)-1] - data_list[0])) print("Interquartile range: " + str(data_list[int(len(data_list)*.75)+1] - data_list[int(len(data_list)*.25)+1])) print("Coefficient of variation: " + str(int(data_stdv/ec.get_average(data_list)*10000)/100) + "%") outliers = [] for value in data_list: if value < ec.get_average(data_list): if value < ec.get_average(data_list) - data_stdv*3: outliers.append(value) elif value > ec.get_average(data_list): if value > ec.get_average(data_list) + data_stdv*3: outliers.append(value) if len(outliers) == 0: