<jupyter_start><jupyter_text>**Imports**<jupyter_code># Import libraries
import math
import scipy.stats as st<jupyter_output><empty_output><jupyter_text>**Mean of Normal Distribution w/ Known Variance OR Any Distribution w/ Large Sample (n>40) (Z-dist)**<jupyter_code># Raw information (PASTE HERE)
x_bar = 68.345
st_dev = 3.7603
alpha = 0.05
n = 40<jupyter_output><empty_output><jupyter_text>Two-sided Interval Estimate<jupyter_code>z = round(st.norm.ppf(alpha/2) * -1, 3);
confidence_variance = abs((st_dev/math.sqrt(n)) * z)
x_bar_l = round(x_bar - confidence_variance, 4)
x_bar_u = round(x_bar + confidence_variance, 4)
print("α/2:", alpha/2, "=> z:", z)
print("Confidence variance:", round(confidence_variance, 4))
print("∴ μ for " + str((1-alpha)*100) + "% C.I. is in [" + str(x_bar_l) + "," + str(x_bar_u) + "]")<jupyter_output>α/2: 0.025 => z: 1.96
Confidence variance: 1.1653
∴ μ for 95.0% C.I. is in [67.1797,69.5103]<jupyter_text>One-sided Interval Estimate (Upper Confidence Bound)<jupyter_code>z = round(st.norm.ppf(alpha) * -1, 3);
confidence_variance = abs((st_dev/math.sqrt(n)) * z)
x_bar_u = round(x_bar + confidence_variance, 4)
print("α:", alpha, "=> z:", z)
print("Confidence variance:", round(confidence_variance, 4))
print("∴ μ for " + str((1-alpha)*100) + "% C.I. is in [-∞," + str(x_bar_u) + "]")<jupyter_output>α: 0.02 => z: 2.054
Confidence variance: 0.4413
∴ μ for 98.0% C.I. is in [-∞,7.9413]<jupyter_text>One-sided Interval Estimate (Lower Confidence Bound)<jupyter_code>z = round(st.norm.ppf(alpha) * -1, 3);
confidence_variance = abs((st_dev/math.sqrt(n)) * z)
x_bar_l = round(x_bar - confidence_variance, 4)
print("α:", alpha, "=> z:", z)
print("Confidence variance:", round(confidence_variance, 4))
print("∴ μ for " + str((1-alpha)*100) + "% C.I. is in [" + str(x_bar_l) + ",∞]")<jupyter_output>α: 0.02 => z: 2.054
Confidence variance: 0.4413
∴ μ for 98.0% C.I. is in [7.0587,∞]<jupyter_text>**Mean of Normal Distribution w/ Unknown Variance (T-dist)**<jupyter_code># Raw information (PASTE HERE)
x_bar = 67.27
s_st_dev = 2.9451
alpha = 0.05
n = 10
df = n - 1 # degree of freedom, can change here<jupyter_output><empty_output><jupyter_text>Two-sided Interval Estimate<jupyter_code>t = round(st.t.ppf(alpha/2, df) * -1, 3);
confidence_variance = abs((s_st_dev/math.sqrt(n)) * t)
x_bar_l = round(x_bar - confidence_variance, 4)
x_bar_u = round(x_bar + confidence_variance, 4)
print("α/2:", str(alpha/2) + ", df:",df,"=> t:", t)
print("Confidence variance:", round(confidence_variance, 4))
print("∴ μ for " + str((1-alpha)*100) + "% C.I. is in [" + str(x_bar_l) + "," + str(x_bar_u) + "]")<jupyter_output>α/2: 0.025, df: 9 => t: 2.262
Confidence variance: 2.1067
∴ μ for 95.0% C.I. is in [65.1633,69.3767]<jupyter_text>One-sided Interval Estimate (Upper Confidence Bound)<jupyter_code>t = round(st.t.ppf(alpha, df) * -1, 3);
confidence_variance = abs((s_st_dev/math.sqrt(n)) * t)
x_bar_u = round(x_bar + confidence_variance, 4)
print("α:", str(alpha) + ", df:",df,"=> t:", t)
print("Confidence variance:", round(confidence_variance, 4))
print("∴ μ for " + str((1-alpha)*100) + "% C.I. is in [-∞," + str(x_bar_u) + "]")<jupyter_output>α: 0.05, df: 21 => t: 1.721
Confidence variance: 1.3026
∴ μ for 95.0% C.I. is in [-∞,15.0126]<jupyter_text>One-sided Interval Estimate (Lower Confidence Bound)<jupyter_code>t = round(st.t.ppf(alpha, df) * -1, 3);
confidence_variance = abs((s_st_dev/math.sqrt(n)) * t)
x_bar_l = round(x_bar - confidence_variance, 4)
print("α:", str(alpha) + ", df:",df,"=> t:", t)
print("Confidence variance:", round(confidence_variance, 4))
print("∴ μ for " + str((1-alpha)*100) + "% C.I. is in [" + str(x_bar_l) + ",∞]")<jupyter_output>α: 0.05, df: 21 => t: 1.721
Confidence variance: 1.3026
∴ μ for 95.0% C.I. is in [12.4074,∞]<jupyter_text>**Variance/SD of Normal Distribution (Chi2-dist)**<jupyter_code># Raw information (PASTE HERE)
s_variance = 841.6667 # IMPORTANT => IF USING SD YOU HAVE TO SQUARE IT
alpha = 0.05
n = 100
df = n - 1 # degree of freedom, can change here<jupyter_output><empty_output><jupyter_text>Two-sided Interval Estimate<jupyter_code>chi_1_minus_alpha_div_2 = round(st.chi2.ppf(alpha/2, df), 3)
chi_alpha_div_2 = round(st.chi2.ppf(1 - (alpha/2), df), 3)
var_l = round(((n-1)*(s_variance)/chi_alpha_div_2), 4)
var_u = round(((n-1)*(s_variance)/chi_1_minus_alpha_div_2), 4)
std_l = round(math.sqrt(((n-1)*(s_variance)/chi_alpha_div_2)), 4)
std_u = round(math.sqrt(((n-1)*(s_variance)/chi_1_minus_alpha_div_2)), 4)
print("α/2:", str(alpha/2) + ", df:",df,"=> chi(alpha/2):", chi_alpha_div_2, "and chi(1 - (alpha/2)):", chi_1_minus_alpha_div_2)
print("∴ σ^2 (variance) for " + str((1-alpha)*100) + "% C.I. is in [" + str(var_l) + "," + str(var_u) + "]")
print("∴ σ (S.D.) for " + str((1-alpha)*100) + "% C.I. is in [" + str(std_l) + "," + str(std_u) + "]")<jupyter_output>α/2: 0.025, df: 99 => chi(alpha/2): 128.422 and chi(1 - (alpha/2)): 73.361
∴ σ^2 (variance) for 95.0% C.I. is in [648.8375,1135.8215]
∴ σ (S.D.) for 95.0% C.I. is in [25.4723,33.702]<jupyter_text>One-sided Interval Estimate (Upper Confidence Bound)<jupyter_code>chi_1_minus_alpha = round(st.chi2.ppf(alpha, df), 3)
var_u = round(((n-1)*(s_variance)/chi_1_minus_alpha), 4)
std_u = round(math.sqrt(((n-1)*(s_variance)/chi_1_minus_alpha)), 4)
print("α:", str(alpha) + ", df:",df,"=> chi(1 - (alpha)):", chi_1_minus_alpha)
print("∴ σ^2 (variance) for " + str((1-alpha)*100) + "% C.I. is in [-∞," + str(var_u) + "]")
print("∴ σ (S.D.) for " + str((1-alpha)*100) + "% C.I. is in [-∞," + str(std_u) + "]")<jupyter_output>α: 0.05, df: 19 => chi(1 - (alpha)): 10.117
∴ σ^2 (variance) for 95.0% C.I. is in [-∞,0.0287]
∴ σ (S.D.) for 95.0% C.I. is in [-∞,0.1695]<jupyter_text>One-sided Interval Estimate (Lower Confidence Bound)<jupyter_code>chi_alpha = round(st.chi2.ppf(1 - (alpha), df), 3)
var_l = round(((n-1)*(s_variance)/chi_alpha), 4)
std_l = round(math.sqrt(((n-1)*(s_variance)/chi_alpha)), 4)
print("α:", str(alpha) + ", df:",df,"=> chi(alpha):", chi_alpha)
print("∴ σ^2 (variance) for " + str((1-alpha)*100) + "% C.I. is in [" + str(var_l) + ",∞]")
print("∴ σ (S.D.) for " + str((1-alpha)*100) + "% C.I. is in [" + str(std_l) + ",∞]")<jupyter_output>α: 0.05, df: 19 => chi(alpha): 30.144
∴ σ^2 (variance) for 95.0% C.I. is in [0.0096,∞]
∴ σ (S.D.) for 95.0% C.I. is in [0.0982,∞]<jupyter_text>**Mean of Binomial (Z-dist)**<jupyter_code><jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2182867842097051, 'fraction_numerical': 0.06756124200343268, 'mean_word_length': 5.163461538461538, 'pattern_counts': {'":': 0, '<': 48, '<?xml version=': 0, '>': 68, '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': '14', 'dir': 'jupyter-structured-clean-dedup', 'id': '405492', 'license': 'MIT', 'n_tokens_mistral': 3151, 'n_tokens_neox': 2824, 'n_words': 599, 'path': 'ConfidenceIntervals.ipynb', 'repo_name': 'wasurocks/PowerStats', 'size': '6409'}