Given a list of integers, e.g. 1, 2, 3, 4
, I know how to select items based on their weight. The example items would have probabilities of 10%, 20%, 30%, and 40%, respectively.
Is there an equally simple method of selecting items based on the inverse of their weight? With this method, the example list would be equal to a weighted list of 1, 1/2, 1/3, 1/4
(48%, 24%, 16%, 12%), but I want to avoid the conversion and use of floating-point arithmetic. (Assume all of the integers are positive and non-zero.)