I took some weights from coworkers, bootstrapped 1000 runs where each run samples 3 values from the original data and appends the minimum, and now I'm trying to curve fit these values to an exponential fit. When I plot the histogram, it isn't a pretty exponential value, but I think I'm doing something wrong because I just get out a flat line.
The value sample below contains the 1000 samples (each the minimum value of a sample of 3 from the original data)
figure = plt.figure(figsize=(10, 6)) # first element is width, second is height.
axes = figure.add_subplot(1, 1, 1)
#axes.hist( sample, density=True, color="dimgray") # a density
axes.set_ylabel( "Density")
axes.set_xlabel( "Weights")
axes.set_title( "Coworker Weights")
ys, bins = np.histogram(sample,bins = 7)
axes.plot(bins[:-1],ys)
print(bins,ys)
This plot comes out to next picture which is something ugly, but I still think it should fit to a curve:
Next I try to fit the data:
def func(x, a, b, c):
return a * np.exp(-b * x) + c
weights = np.array(weights)
popt, pcov = curve_fit(func, bins[:-1], ys)
print(popt)
figure = plt.figure(figsize=(10, 6)) # first element is width, second is height.
axes = figure.add_subplot(1, 1, 1)
plt.plot(weights, func(weights, *popt))
The weights array is my original data. The output I get is just a flat line, and the popt coefficients are [1,1,143]
. What am I doing wrong?