2. Fit a Poisson distribution to the following data and test for its goodness of fit. No. Of patients 0 1 2 3 4 5 6 No. Of days 153 169 72 31 12 6 2 import pandas as pd import numpy as np from scipy.stats import poisson table = pd.read_excel("C:/Users/Naveen/OneDrive/Desktop/Poisson_distribution.xlsx") table x = table[' No. Of patients '] x f = table[‘No. Of days’] f fx =f*x m = sum(fx)/sum(f) px = poisson.pmf(x,m) px1 = np.round(px,4) px1 ef =sum(f)*px ef ef1 = np.round(ef,0) ef1 15 Peddi Rajini, Assistant Professor, Department of Mathematics and Statistics, BVC, Sainikpuri, Secunderabad #perform Chi-Square Goodness of Fit Test stats.chisquare(f_obs=f, f_exp=ef1) if pval <0.05: print("reject null hypothesis") else: print("accept null hypothesis")
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter