diff --git a/README.md b/README.md index c162b719..fcdac21d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +# DATE : # Fitting Poisson distribution # Aim : @@ -30,9 +31,49 @@ The Poisson distribution is the discrete probability distribution of the number # Program : +DEVELOPED BY : V.SAI SRUTHI +REGISTER NUMBER : 212223100061 + +import numpy as np +import math +import scipy.stats +L=[int(i) for i in input().split()] +N=len(L); M=max(L) +X=list();f=list() +for i in range (M+1): + c = 0 + for j in range(N): + if L[j]==i: + c=c+1 + f.append(c) + X.append(i) +sf=np.sum(f) +p=list() +for i in range(M+1): + p.append(f[i]/sf) +mean=np.inner(X,p) +p=list();E=list();xi=list() +print("X P(X=x) Obs.Fr Exp.Fr xi") +print("--------------------------") +for x in range(M+1): + p.append(math.exp(-mean)*mean**x/math.factorial(x)) + E.append(p[x]*sf) + xi.append((f[x]-E[x])**2/E[x]) + print("%2.2f %2.3f %4.2f %3.2f %3.2f"%(x,p[x],f[x],E[x],xi[x])) +print("--------------------------") +cal_chi2_sq=np.sum(xi) +print("Calculated value of Chi square is %4.2f"%cal_chi2_sq) +table_chi2=scipy.stats.chi2.ppf(1-.01,df=M) +print("Table value of chi square at 1 level is %4.2f"%table_chi2) +if cal_chi2_sq