<jupyter_start><jupyter_text>Simulating From the Null HypothesisLoad in the data below, and use the exercises to assist with answering the quiz questions below.**If you get stuck, notice there is a solution notebook available by clicking on the orange jupyter icon in the top left!**<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

%matplotlib inline
np.random.seed(42)

full_data = pd.read_csv('coffee_dataset.csv')
sample_data = full_data.sample(200)<jupyter_output><empty_output><jupyter_text>`1.` If you were interested in studying whether the average height for coffee drinkers is the same as for non-coffee drinkers, what would the null and alternative hypotheses be?  Write them in the cell below, and use your answer to answer the first quiz question below. H0: μcoff - μnocoff = 0   H1: μcoff - μnocoff != 0  μ = average height of all coffee drinkers      `2.` If you were interested in studying whether the average height for coffee drinkers is less than non-coffee drinkers, what would the null and alternative hypotheses be?  Write them in the cell below, and use your answer to answer the second quiz question below. H0: μcoff - μnocoff <= 0   H1: μcoff - μnocoff > 0  μ = average height of all coffee drinkers      `3.` For 10,000 iterations: bootstrap the sample data, calculate the mean height for coffee drinkers and non-coffee drinkers, and calculate the difference in means for each sample.  You will want to have three arrays at the end of the iterations - one for each mean and one for the difference in means.  Use the results of your sampling distribution, to answer the third quiz question below.<jupyter_code>coff, nocoff, diffs = [],[],[]

for _ in range(10000):
    bootsamp = sample_data.sample(200, replace = True)
    coff_mean = bootsamp[bootsamp['drinks_coffee'] == True]['height'].mean()
    nocoff_mean = bootsamp[bootsamp['drinks_coffee'] == False]['height'].mean()
    coff.append(coff_mean)
    nocoff.append(nocoff_mean)
    diffs.append(coff_mean - nocoff_mean) 
np.std(coff)
np.std(nocoff)
np.std(diffs)
plt.hist(coff, alpha=0.5);
plt.hist(nocoff, alpha=0.5);
plt.hist(diffs, alpha=0.5);<jupyter_output><empty_output><jupyter_text>`4.` Now, use your observed sampling distribution for the difference in means and [the docs](https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.random.normal.html) to simulate what you would expect the sampling distribution to be if the null hypothesis is true. You can do this be recentering your distribution at zero. Also, calculate the observed sample mean difference in `sample_data`. Use your solutions to answer the last questions in the quiz below.<jupyter_code>null_vals = np.random.normal(0, np.std(diffs), 10000)
plt.hist(null_vals, alpha =0.7);<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08401566393734425, 'fraction_numerical': 0.017087931648273408, 'mean_word_length': 4.9033613445378155, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 1, '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': '560092', 'license': 'MIT', 'n_tokens_mistral': 888, 'n_tokens_neox': 839, 'n_words': 340, 'path': 'Hypothesis testing/Simulating from the Null_1.ipynb', 'repo_name': 'nilaychauhan/statistics-and-probability', 'size': '2809'}