Skip to main content

Weighted Bag

Overview

Weighted bags are distributions with a limited count of each item, as well as an integer weight for each item. Each item's probability equals its weight divided by the total weight of all items. Each item's probability does not change until the item's count reaches 0.

Example 1

Suppose we have a weighted bag of colored balls:

Distribution A (Weighted Bag)
ColorCountWeightProbability
Red310033% (100 / 300)
Blue210033% (100 / 300)
Green510033% (100 / 300)

Suppose we sample Red from the bag. It becomes:

Distribution A (After Sampling Red)
ColorCountWeightProbability
Red210033% (100 / 300)
Blue210033% (100 / 300)
Green510033% (100 / 300)

Although red's count changed, its probability is still the same. Suppose we sampled Red twice more:

Distribution A (After Sampling Red x2)
ColorCountWeightProbability
Red01000% (Ineligible)
Blue210050% (100 / 200)
Green510050% (100 / 200)

Now red's count has become 0 and it is ineligible.

Example 2

Items are ineligible when Count = 0 OR Weight = 0.

Distribution B (Weighted Bag)
ColorCountWeightProbability
Red01000% (Ineligible)
Blue200% (Ineligible)
Green5100100% (100 / 100)

Advanced

Eligibility

Count > 0 and Weight > 0.