<jupyter_start><jupyter_text>Generate random numbers:<jupyter_code>r = norm.rvs(size=1000)<jupyter_output><empty_output><jupyter_text>And compare the histogram:<jupyter_code>ax.histar, density=True, histtype='stepfilled', alpha=0.2)
ax.legend(loc='best', frameon=False)
plt.show()
from scipy.stats import binom
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
fig, ax = plt.subplots(1, 1)
n, p = 4, 0.1
mean, var, skew, kurt = binom.stats(n, p, moments='mvsk')
x = np.arange(binom.ppf(0.05, n, p),binom.ppf(0.95, n, p))
ax.plot(x, binom.pmf(x, n, p), 'bo', ms=8, label='binom pmf')
ax.vlines(x, 0, binom.pmf(x, n, p), colors='b', lw=5, alpha=0.5)
fig
y=binom.pmf(x,n,p)
y
rv = binom(n, p)
ax.vlines(x, 0, rv.pmf(x), colors='k', linestyles='-', lw=1,label='frozen pmf')
ax.legend(loc='best', frameon=False)
fig
rv.pmf(1)
from scipy import stats
stats.binom(281, n=550, p= 0.5).pmf(.511)<jupyter_output><empty_output><jupyter_text>Calulating A Binomial Probability:<jupyter_code>from scipy.stats import binom
import numpy as np
x=281
n=550
p=.5
prob = binom.cdf(x,n,p)
print('inclusive')
print(prob)
np.allclose(x, binom.ppf(prob, n, p))
# # rember cdf is cummulative so you must subtract from 1 to get real prob estimate for oppostite cum sum side 
### THIS IS FUCKING IMMPORTANT FUCKER
print('noninclusive')
real=(1-(prob))
print(round(real,4))
np.allclose(x, binom.ppf(real, n, p))<jupyter_output>inclusive
0.7103007226822806
noninclusive
0.2897
{'fraction_non_alphanumeric': 0.16768916155419222, 'fraction_numerical': 0.046353101567825496, 'mean_word_length': 6.489795918367347, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '408323', 'license': 'Unlicense', 'n_tokens_mistral': 688, 'n_tokens_neox': 634, 'n_words': 145, 'path': 'readme_files/Binomial_calulation.ipynb', 'repo_name': 'dreamscape08/Business_Statistics_Scripts', 'size': '1467'}