I would like to make a lognormal fit to my already binned data. The bar plot looks like this:
Unfortunately, when I try to use the standard lognorm.pdf() the shape of the fitted distribution is very different. I guess it's because my data is already binned. Here's the code:
times, data, bin_points = ReadHistogramFile(filename)
xmin = 200
xmax = 800
x = np.linspace(xmin, xmax, 1000)
shape, loc, scale = stats.lognorm.fit(data, floc=0)
pdf = stats.lognorm.pdf(x, shape, loc=loc, scale=scale)
area=data.sum()
plt.bar(bars, data, width=10, color='b')
plt.plot(x*area, pdf, 'k' )
Here's what the fitted distribution looks like: