<jupyter_start><jupyter_text>chap3 q24 Based on a histogram of the variable "perday", do you think the mean or median of this variable is larger? Calculate the mean and median to see if you are right.<jupyter_code>flatulence.hist('perday')
print("mean="+str(flatulence.perday.mean()))
print("median="+str(flatulence.perday.median()))<jupyter_output>mean=3.823529411764706
median=3.0<jupyter_text>chap4 q19 Is there a relationship between the number of male siblings and embarrassment in front of romantic interests? Create a scatterplot and compute r.<jupyter_code>from scipy.stats.stats import pearsonr
flatulence.plot.scatter('brother', 'romint')
pearsonr(flatulence['brother'], flatulence['romint'])<jupyter_output><empty_output><jupyter_text>Chapter 10 "Estimation" Exercises Q27 Compare men and women on the variable "perday." Compute the 95% confidence interval on the difference between means.<jupyter_code>males = flatulence[flatulence["Gender"]==1]['perday']
females = flatulence[flatulence["Gender"]==2]['perday']
print(len(females))
print(len(males))
#lengths are the same so we can do this normally
#diff bw means
mean = males.mean()-females.mean()

#use to estiamte var of diff between two samples
var_est = (males.var()+females.var())/2

#use var to estimate std of diff
std_est = ((2 * var_est)/17)**.5

#calc df
df = 17-1+17-1

#find t for df=32 and .05 two tail
t = 2.042

print("lower limit= "+str(mean - t * std_est))
print("upper limit= "+str(mean + t * std_est))<jupyter_output>lower limit= -3.098614289340502
upper limit= 0.9809672305169732
{'fraction_non_alphanumeric': 0.1235595390524968, 'fraction_numerical': 0.05377720870678617, 'mean_word_length': 6.550724637681159, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '290468', 'license': 'MIT', 'n_tokens_mistral': 586, 'n_tokens_neox': 524, 'n_words': 159, 'path': 'case_studies/.ipynb_checkpoints/flatulence_case_study-checkpoint.ipynb', 'repo_name': 'aicharles/online_stats_book_python', 'size': '1562'}