<jupyter_start><jupyter_text>Using t-value<jupyter_code># lookup critical val from table, 5% significance level at d0f = 24
t_c = -1.711
if t < t_c:
    print("reject null, with t-score = %.2f"%t)
else:
    print("cannot reject null, with t-score = %.2f"%t)<jupyter_output>reject null, with t-score = -2.50<jupyter_text>Using p-value<jupyter_code># significance level
alpha = 0.05

# lookup p-value using sample t-score
# note that this is left-tailed, and t < 0
p = st.t.cdf(t, df=sample_size - 1)
if p < alpha:
    print("reject null, with p-val = %.5f"%(p))
else:
    print("cannot reject null, with p-val = %.5f"%(p))<jupyter_output>reject null, with p-val = 0.00983<jupyter_text>effect size statistics<jupyter_code># cohen's d
(sample_mean - mu_0) / sample_std
# r-square
ddof = sample_size - 1
t ** 2 / (t ** 2 + ddof)<jupyter_output><empty_output><jupyter_text>Confidence interval* for 95% confidence level, 2-tailed.* notice we __cannot__ use t-score from sample, which is 1-tailed.<jupyter_code># margin of error,
z_2t = 2.064
me = z_2t * se
# upper bound
sample_mean + me
# lower bound
sample_mean - me<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13485113835376533, 'fraction_numerical': 0.03502626970227671, 'mean_word_length': 4.4951923076923075, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 15, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '181372', 'license': 'MIT', 'n_tokens_mistral': 475, 'n_tokens_neox': 442, 'n_words': 124, 'path': 'statistics_test/t_test_one_sample_left_tail.ipynb', 'repo_name': 'shawlu95/Data_Science_Toolbox', 'size': '1142'}