<jupyter_start><jupyter_text>DC Trains<jupyter_code>import numpy as np
from scipy import stats<jupyter_output><empty_output><jupyter_text>Answer the following question:People in DC constantly complain that the metro consistently runs an average of 10 minutes late. You actually think it’s less than this, so you gather data for ten different trains at a specific location in DC. The following is your data in minutes of lateness: [4, 12, 6, 2, 1, 6, 7, 3, 16, 0]. Based on your data, are the people in DC correct?<jupyter_code>lateness = np.array([4, 12, 6, 2, 1, 6, 7, 3, 16, 0])<jupyter_output><empty_output><jupyter_text>We need to compute t as shown below:$$ t = \frac{\bar{x} - \mu}{\frac{s}{\sqrt{n}}} $$<jupyter_code>x_bar = lateness.mean()
x_bar<jupyter_output><empty_output><jupyter_text>\\(\mu\\) is our average fill that we are testing our hypothesis against<jupyter_code>mu = 10<jupyter_output><empty_output><jupyter_text>Sample standard deviation needs degress of freedom \\(n-1\\)<jupyter_code>s = lateness.std(ddof=1)
s<jupyter_output><empty_output><jupyter_text>n is our number of samples<jupyter_code>n = lateness.shape[0]
n
t = (x_bar - mu) / (s / np.sqrt(n))
t<jupyter_output><empty_output><jupyter_text>Left tailed significance value<jupyter_code>alpha = (1.0 - 0.95)
alpha<jupyter_output><empty_output><jupyter_text>Now find the p-value for the t statistic with the link above. Use the t distribution CDF. Set x to be your t score and df to be the degrees of freedom \\(n-1\\).<jupyter_code>p = stats.t.cdf(x=t,df=n-1)
p<jupyter_output><empty_output><jupyter_text>Can we reject \\(H_0\\)?<jupyter_code>p <= alpha<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12447384245339747, 'fraction_numerical': 0.02345159350571257, 'mean_word_length': 5.96234309623431, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 37, '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': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '344153', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 645, 'n_tokens_neox': 610, 'n_words': 178, 'path': 'boulder/DC_Trains.ipynb', 'repo_name': 'GalvanizeOpenSource/bdr-platte-intro-to-ds-oct-2018', 'size': '1663'}