Test the best-fit distribution and return parameter and 'p' values

ipython
data_science
python

#1

My data set fits gamma and weibull distribution. I need to compare which one is the best fit with respect to p values and return the shape and scale values, loc parameter needs to be set to zero

Also I have used this code:

x = np.arange(0,10,.1)
y1=file1.SMS
shape1, loc1, scale1 = gamma.fit(y1)
g1 = gamma.pdf( x=x, a=shape1, loc=loc1, scale=scale1)

fig, axes = plt.subplots(1, 3, figsize=(13,4))
ax = axes[0]
ax.hist(y1, bins=40, normed=True);
ax.plot(x, g1, 'r-', linewidth=6, alpha=.6)
ax.annotate(s='shape = %.3f\nloc = %.3f\nscale = %.3f' %(shape1, loc1, scale1), xy=(6,.2))
ax.set_title('gamma fit')

but it does not give the desired output


#2

Hi @shruti.bothe,

As you mentioned, the dataset fits gamma and weibull distribution, you can compare these on the basis of p-value.

Regarding the code, what is the desired output that you are looking for?

If this is about the two blank charts, in the code, you have assigned values only for axes[0] and nothing for axes[1] and axes[2].