return np.interp(np.linspace(0, npt, nbin + 1), np.arange(npt), np.sort(x))
x = np.random.randn(100)
n, bins, patches = plt.hist(x, histedges_equalN(x, 10))
Histogram with equal number of points in each bin