much faster using np.histogram