<jupyter_start><jupyter_text><jupyter_code># Setting up normal distribution with a mean of 3 and standard deviation of 2 with 10,000 observations.
import numpy as np
mu, sigma = 3, 2
s = np.random.normal(mu, sigma, 10000)
# Plotting the normal distribution with a histogram in matplotlib 

import matplotlib.pyplot as plt
from scipy.stats import norm
plt.hist(s, bins = 30, density=True)

m, std = norm.fit(s)

x = np.linspace(-4, 10, 100)
p = norm.pdf(x, m, std)
plt.plot(x, p, color='red')

plt.show()

# Comparing the original normal distribution to a sample with a mean of 1.5 and a standard deviation of 2.

sample_mean, sample_sigma = 1.5, 2
sample = np.random.normal(sample_mean, sample_sigma, 200)

count, bins, ignored = plt.hist(s, 30, alpha = 0.1, density = True)
count, bins, ignored = plt.hist(sample, 30, alpha = 0.1, density = True)

m, std = norm.fit(s)
m_samp, std_samp = norm.fit(sample)


x = np.linspace(-4, 10, 100)
x_samp = np.linspace(-4, 10, 200)
p = norm.pdf(x, m, std)
p_samp = norm.pdf(x_samp, m_samp, std_samp)
plt.plot(x, p, color='blue')
plt.plot(x_samp, p_samp, color = 'red')


plt.show()

# Plotting the Type 1 Errors, Type 2 Error, Confidence Intervals, Null Hypothesis, and Alternate Hypothesis

sample_mean, sample_sigma = 1.5, 2
sample = np.random.normal(sample_mean, sample_sigma, 200)

count, bins, ignored = plt.hist(s, 30, alpha = 0.1, density = True)
count, bins, ignored = plt.hist(sample, 30, alpha = 0.1, density = True)

m, std = norm.fit(s)
m_samp, std_samp = norm.fit(sample)


x = np.linspace(-4, 10, 100)
x_samp = np.linspace(-4, 10, 200)
p = norm.pdf(x, m, std)
p_samp = norm.pdf(x_samp, m_samp, std_samp)
plt.plot(x, p, color='blue')
plt.plot(x_samp, p_samp, color = 'red')

ci = norm.interval(0.95, loc= np.mean(sample), scale = sigma)
plt.axvline(ci[0],color='g')
plt.axvline(ci[1],color='g')
plt.annotate(xy=[-4,0.01], s = 'Type 1 Error')
plt.annotate(xy=[6,0.01], s = 'Type 1 Error')
plt.annotate(xy=[2,0.03], s = 'Type 2 Error')
plt.annotate(xy=[6,0.05], s = 'Alternative')
plt.annotate(xy=[0,0.18], s = 'Null Hypothesis')

type1_x1 = [-4, ci[0]]
type1_y1 = [0, 0.025]
plt.fill_between(type1_x1, type1_y1, color = 'red', alpha = 0.5)

type1_x2 = [ci[1], 7.4]
type1_y2 = [0.025,0]
plt.fill_between(type1_x2, type1_y2, color = 'red', alpha = 0.5)

type2_x = [ci[0], -1, 0, 1, 2, 3, 4, 5, ci[1]]
type2_y = [0, 0.03, 0.06, 0.12, 0.18, 0.20, 0.18, 0.12, 0.10]
plt.fill_between(type2_x, type2_y, color = 'blue', alpha = 0.5)


plt.show()
# Calculating the z-score
(sample_mean - mu)/sigma<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16578549848942598, 'fraction_numerical': 0.06873111782477341, 'mean_word_length': 3.8339416058394162, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '277961', 'license': 'MIT', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1138, 'n_words': 296, 'path': 'Week2_Homework.ipynb', 'repo_name': 'deshanahan/DATA-602-Homework', 'size': '2648'}