import sys # allows import of project files (idk how else to do this) sys.path.insert(1, '..') from utils.webassign import array_from_shitstring from stats import mean, deviation_from_mean, variance, standard_deviation youngs_mod = array_from_shitstring(" 116.6 115.8 114.9 115.3 115.6 ") youngs_mod.sort() print("Young's Mod: {}".format(youngs_mod)) sample_mean = mean(youngs_mod) print("Young's Mod (mean): {}".format(sample_mean)) print("Deviation from mean:") deviation_list = deviation_from_mean(youngs_mod) for data_point, deviation in zip(youngs_mod, deviation_list): print("Sample: {0}, deviation from mean: {1}".format( data_point, deviation)) my_variance = variance(youngs_mod) print("Sample variance: {}".format(my_variance)) print("Standard deviation: {}".format(standard_deviation(youngs_mod)))
import sys sys.path.insert(1, '..') from utils.webassign import array_from_shitstring particles_shit = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14" freq_shit = "1 1 3 12 11 15 20 10 9 4 5 3 3 2 1" particles = array_from_shitstring(particles_shit) freq = array_from_shitstring(freq_shit) together = dict(zip(particles, freq)) print(together) at_least_5 = [value for key, value in together.items() if key >= 5] print("Values above 5: {0}".format(at_least_5)) print("Sum: {}".format(sum(at_least_5))) inclusive = [value for key, value in together.items() if 5 <= key <= 10] exclusive = [value for key, value in together.items() if 5 < key < 10] print("Between 5 and 10, inclusive: {}".format(sum(inclusive))) print("Between 5 and 10, exclusive: {}".format(sum(exclusive)))
import sys # allows import of project files (idk how else to do this) sys.path.insert(1, '..') from utils.webassign import array_from_shitstring from stats import median from utils.helpers import round_to_nearest_interval actual_pressure = array_from_shitstring( "128.6 137.8 148.4 140.0 123.7 132.0 118.3 141.5 143.2 ") actual_pressure.sort() print("Actual pressure: {}".format(actual_pressure)) rounded_pressure = round_to_nearest_interval(actual_pressure, 5) print("Rounded pressure: {0}".format(rounded_pressure)) median_rounded_pressure = median(rounded_pressure) print("Median (rounded pressure): {0}".format(median_rounded_pressure))
# setup import sys sys.path.insert(1, '..') from utils.webassign import array_from_shitstring from stats import mean, median # string to array urban = array_from_shitstring( "6.0 5.0 11.0 33.0 4.0 5.0 80.0 18.0 35.0 17.0 23.0 ") farm = array_from_shitstring( "4.0 12.0 10.0 7.0 9.0 8.0 3.0 20.0 3.0 9.3 21.0 9.1 2.0 1.0 0.1") urban.sort() farm.sort() print("Urban: {}".format(urban)) print("Farm: {}".format(farm)) # determine sample mean for each print("Concentration mean for urban homes (EU/mg): {}".format(mean(urban))) print("Concentration mean for farm homes (EU/mg): {}".format(mean(farm))) # determine sample median for each print("Sample median for urban homes (EU/mg): {}".format(median(urban))) print("Sample median for farm homes (EU/mg): {}".format(median(farm))) # calculate trimmed mean by dropping first and last elements urban.sort() farm.sort() # trim urban_trimmed = urban[1:-1]
This file contains some default imports and commonly used functions so that you don't have to write lots of code over and over for each problem. """ # CONFIG PROJECT_ROOT = '..' # relative location pointing to utils/ and stats.py # REST OF FILE import sys # allows import of project files (idk how else to do this) sys.path.insert(1, PROJECT_ROOT) from utils.webassign import array_from_shitstring from stats import frequency, relative_frequency keys = array_from_shitstring('1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17') values = array_from_shitstring('740 204 127 50 33 28 19 19 6 7 6 7 4 4 5 3 3') papers_and_freq = dict(zip(keys, values)) print(papers_and_freq) at_least_5_papers = sum( [papers_and_freq[key] for key in papers_and_freq if key >= 5]) at_least_10_papers = sum( [papers_and_freq[key] for key in papers_and_freq if key >= 10]) more_than_10_papers = sum( [papers_and_freq[key] for key in papers_and_freq if key > 10]) total_values = sum([papers_and_freq[key] for key in papers_and_freq]) print("at least 5 papers: {}".format(at_least_5_papers / total_values)) print("at least 10 papers: {}".format(at_least_10_papers / total_values)) print("more than 10 papers: {}".format(more_than_10_papers / total_values))
""" This file contains some default imports and commonly used functions so that you don't have to write lots of code over and over for each problem. """ # CONFIG PROJECT_ROOT = '..' # relative location pointing to utils/ and stats.py # REST OF FILE import sys # allows import of project files (idk how else to do this) sys.path.insert(1, PROJECT_ROOT) from utils.webassign import array_from_shitstring from stats import frequency, relative_frequency data = array_from_shitstring( '1 1 2 3 0 1 3 2 0 5 3 3 1 3 2 4 7 0 2 3 0 4 2 1 3 1 1 3 4 1 2 3 2 2 8 4 5 1 3 1 5 0 2 3 2 1 0 6 4 2 1 6 0 3 3 3 7 1 2 3' ) # put your data here data.sort() freq = frequency(data) print("Data: {}".format(data)) print("frequency: {}".format(freq)) print("relative frequency: {}".format(relative_frequency(freq)))
import sys sys.path.insert(1, '..') from utils.webassign import array_from_shitstring shitstring = "5.6 7.2 7.3 6.3 8.1 6.8 7.0 7.6 6.8 6.5 7.0 6.3 7.9 9.0 8.2 8.7 7.8 9.7 7.4 7.7 9.7 7.8 7.7 11.6 11.5 11.8 10.6" array = array_from_shitstring(shitstring) for number in array: print(number)
don't have to write lots of code over and over for each problem. """ # CONFIG PROJECT_ROOT = '..' # relative location pointing to utils/ and stats.py # REST OF FILE import sys # allows import of project files (idk how else to do this) sys.path.insert(1, PROJECT_ROOT) from utils.webassign import array_from_shitstring from stats import variance, standard_deviation data = array_from_shitstring( "85 105 130 160 180 195 134 145 214 105 145 151 153 135 87 99 94 119 129" ) # put your data here data.sort() print("Oxidation induction time (min): {}".format(data)) data_variance = variance(data) data_standard_deviation = standard_deviation(data) print("Sample variance: {}".format(data_variance)) print("Standard deviation: {}".format(data_standard_deviation)) data_to_hours = [value / 60 for value in data] data_variance_in_hours = variance(data_to_hours) standard_deviation_in_hours = standard_deviation(data_to_hours) print("Sample variance (hrs): {}".format(data_variance_in_hours)) print("Standard deviation (hrs): {}".format(standard_deviation_in_hours))
""" This file contains some default imports and commonly used functions so that you don't have to write lots of code over and over for each problem. """ # CONFIG PROJECT_ROOT = '..' # relative location pointing to utils/ and stats.py # REST OF FILE import sys # allows import of project files (idk how else to do this) sys.path.insert(1, PROJECT_ROOT) from utils.webassign import array_from_shitstring data = array_from_shitstring('DATA_HERE') # put your data here data.sort() print("Data: {}".format(data))