Discrete Distributions
Overview
Discrete distributions define a collection of items which each have a probability of being selected. You can sample from the distribution to select a random item from the collection based on each item's probability.
Discrete distributions are used internally by loot tables for random selection. Each distribution has a different method for randomly selecting items:
- Unlimited: Each item has a probability, and can be sampled an unlimited number of times.
- Grab Bag: This is like putting a bunch of items into a bag and grabbing one at random. Also similar to a deck of cards.
- Weighted Bag: This is like putting a bunch of items into a bag, but each item has a different size. As such, the bigger items are more likely to be sampled.
- Nested Bag: Like a weighted bag, but some items can limit the selections of others.
Usage
Construction
- Spawn a object with the distribution class of your choice using the SpawnObject blueprint node.
- Invoke Initialize on the object.
Sampling
All distributions implement the functions listed in sampling.
Interface
All discrete distributions implement the interface ISTDiscreteDistribution. Some distributions implement ISTLimitedDiscreteDistribution, which implies their items have a limited count.
After construction, all distributions can have item values modified (e.g., weight), but cannot have additional items added/removed. Create a new distribution if you must add or remove items.