<jupyter_start><jupyter_text>Binomial distribution $prob(x) = \frac{n!}{n! (n-x)!}{ p^x q^{(n-x)}}$<jupyter_code>def binomial(x, n, p):
          
    return float(factorial(n)/(factorial(x) * factorial(n - x))) * p ** x * (1 - p)**(n - x)
n=max(DF['Head'])+1
ef=[]        #expected frequency
for x in range(min(DF['Head']), n):
    y =binomial(x, n, 0.5)
    ef.append(round(N*y))
DF['Exp.Freq.']=ef
DF
plt.plot(DF['Head'], ef,'r-',label='Exp.freq.')
plt.plot(DF['Head'], DF['Frequency'],'g-.', label='Obs.freq.')
plt.xlabel("No. of head", fontsize=12)
plt.ylabel("Freqyency", fontsize=12)
plt.legend()
plt.title('Binomial Distribution', fontsize = 16 ,color='blue')
plt.tight_layout() 
plt.show()
chi2=sum((ef-DF['Frequency'])**2/ef)  #DF['Frequency']=obs.frequency
print('chi square is ',chi2)<jupyter_output>chi square is  6.243260090384915
{'fraction_non_alphanumeric': 0.24407582938388625, 'fraction_numerical': 0.034360189573459717, 'mean_word_length': 5.213235294117647, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '508811', 'license': 'MIT', 'n_tokens_mistral': 388, 'n_tokens_neox': 347, 'n_words': 63, 'path': 'coin toss.ipynb', 'repo_name': 'Rabibryan/Tossing-of-coin', 'size': '844'}