rewrite Histogram's .sample in an iterative style