Weighted random sampling with a reservoir

Sampling

Can be used to obtain a set of samples when Rejection sampling rejects too many and slows down.