Use internal sample_with_replacement rather than Python's random.sample