Fixed numpy type error by converting n_kept to int in sampling