resampling function modifies the weights and therefore a copy of the weights is used for resampling particles with zero probability