我在Quod
Libet中发现了这个不错的小算法。您可能可以将其转换为一些过程SQL。
function WeightedShuffle(list of items with weights): max_score ← the sum of every item’s weight choice ← random number in the range [0, max_score) current ← 0 for each item (i, weight) in items: current ← current + weight if current ≥ choice or i is the last item: return item i



