hists = [generate_random_histogram() for x in range(3)]
for h in hists:
    bin_locations = h['loc']
bin_counts = h['count']
bin_edges = np.concatenate([[0], (bin_locations[1:] + bin_locations[:-1]) /
    2, [100]])
bin_widths = np.diff(bin_edges)
bin_density = bin_counts.astype(float) / np.dot(bin_widths, bin_counts)
h['density'] = bin_density
data = np.repeat(bin_locations, bin_counts)
h['kde'] = gaussian_kde(data)
plt.step(bin_locations, bin_density, where='mid', label='normalized')
plt.plot(np.linspace(0, 100), h['kde'](np.linspace(0, 100)), label='kde')
Making Probability Distribution Functions (PDFs) from histograms