Generalized resampled importance sampling