import scipy.stats as st
samp=st.lognorm(0.6,loc=2,scale=1).rvs(size=2000) # sample
param=st.lognorm.fit(samp, floc = 0) # fit the sample data
print(param) # does not coincide with shape, loc, scale above!
x=np.linspace(0,10,100)
pdf_fitted = st.lognorm.pdf(x, param[0], loc=param[1], scale=param[2]) # fitted distribution
print(pdf_fitted)
pdf = st.lognorm.pdf(x, 0.5, loc=0, scale=1) # original distribution
plt.plot(x,pdf_fitted,'r-',x,pdf,'g-', color = "red")
plt.hist(samp,bins=30,normed=True,alpha=.3)
I want to do the lognormal fitting. When I used the above code, "two" fitted-curve were plotted. The first (the peak was around 0.5) might be wrong. The second (the peak was around 3) was the only curve I wanted.
How should I do? I've chacked the similar question, but I cannot understand how to solve it.
Python 3.7.2, scipy 1.7.1, Mac 10.14.5 were used.