ENH: add a resampling function and a corresponding test