def get_hist_density(data, nbins=25): y, x = np.histogram(data, nbins) x = x[1:] - 0.5*(x[1] - x[0]) p = y / trapz(y, x) return [p, x]