Select k random elements from a list whose elements have weights
问题 Selecting without any weights (equal probabilities) is beautifully described here. I was wondering if there is a way to convert this approach to a weighted one. I am also interested in other approaches as well. Update: Sampling without replacement 回答1: I know this is a very old question, but I think there's a neat trick to do this in O(n) time if you apply a little math! The exponential distribution has two very useful properties. Given n samples from different exponential distributions with