import numpy as np import fetchmaker rottweiler_tl = fetchmaker.get_tail_length('rottweiler') print(np.mean(rottweiler_tl), np.std(rottweiler_tl)) whippet_rescue = fetchmaker.get_is_rescue('whippet') num_whippet_rescue = np.count_nonzero(whippet_rescue) print(num_whippet_rescue) num_whippets = np.size(whippet_rescue) print(num_whippets) from scipy.stats import binom_test whippet_binom_test = binom_test(num_whippet_rescue, num_whippets, 0.08) if whippet_binom_test < 0.05: print('Significant Difference!') else: print('No Difference.') from scipy.stats import f_oneway whippet_avg_weight = fetchmaker.get_weight('whippet') terrier_avg_weight = fetchmaker.get_weight('terrier') pitbull_avg_weight = fetchmaker.get_weight('pitbull') weight_t, weight_pval = f_oneway(whippet_avg_weight, terrier_avg_weight, pitbull_avg_weight) if weight_pval < 0.05: print('There is a difference between these breeds!') else:
import numpy as np import fetchmaker from scipy.stats import binom_test from scipy.stats import f_oneway from statsmodels.stats.multicomp import pairwise_tukeyhsd from scipy.stats import chi2_contingency rottweiler_tl = fetchmaker.get_tail_length("rottweiler") print(np.mean(rottweiler_tl)) print(np.std(rottweiler_tl)) """ Over the years, we have seen that we expect 8% of dogs in the FetchMaker system to be rescues. We want to know if whippets are significantly more or less likely to be a rescue. """ whippet_rescue = fetchmaker.get_is_rescue("whippet") num_whippet_rescues = np.count_nonzero(whippet_rescue) print(num_whippet_rescues) num_whippets = np.size(whippet_rescue) print(num_whippets) pval = binom_test(num_whippet_rescues, n=num_whippets, p=0.08) print(pval) """ Three of our most popular mid-sized dog breeds are whippets, terriers, and pitbulls. Is there a significant difference in the average weights of these three dog breeds? Perform a comparative numerical test to determine if there is a significant difference. """ whippet_weight = fetchmaker.get_weight("whippet") terrier_weight = fetchmaker.get_weight("terrier") pitbull_weight = fetchmaker.get_weight("pitbull") print(np.size(whippet_weight)) print(np.size(terrier_weight)) print(np.size(pitbull_weight))
import fetchmaker as fm import numpy as np from scipy.stats import binom_test from scipy.stats import f_oneway from statsmodels.stats.multicomp import pairwise_tukeyhsd from scipy.stats import chi2_contingency rottweiler_tl = fm.get_tail_length("rottweiler") print(np.mean(rottweiler_tl)) print(np.std(rottweiler_tl)) whippet_rescue = fm.get_is_rescue("whippet") num_whippet_rescues = np.count_nonzero(whippet_rescue) num_whippets = np.size(whippet_rescue) pval = binom_test(num_whippet_rescues, num_whippets, p=0.08) print(pval) # pval > 0.05 : Not significant whippet_wg = fm.get_weight("whippet") terrier_wg = fm.get_weight("terrier") pitbull_wg = fm.get_weight("pitbull") pval2 = f_oneway(whippet_wg, terrier_wg, pitbull_wg).pvalue print(pval2) # pval > 0.05 : Not significant weights = np.concatenate([whippet_wg, terrier_wg, pitbull_wg]) labels = ["Whippet"] * len(whippet_wg) + ["Terrier"] * len(terrier_wg) + ["Pitbull"] * len(pitbull_wg)