Skip to main content

Glossary

Sampling

Sampling means drawing a random item from a discrete distribution, loot table, or other sample-able object. For example, suppose we had the following distribution:

Distribution A (Unlimited)
IndexWeightProbability
010010%
120020%
270070%

If we 'Sample' from this distribution, we will receive one index from {0, 1, 2}, with respective probabilities {10%, 20%, 70%}.

Counts

Some distributions have counts associated with each item, meaning only a limited number of samples can be drawn of that item. E.g.:

Distribution B (Weighted Bag)
IndexWeightProbabilityCount
010010%1
120020%2
270070%3

If we sampled item '0', its count would be reduced from 1 -> 0. Consequently, this means it is no longer eligible (it can't be sampled).

Depletion

Distributions with counts may become depleted, meaning they have no items remaining that can be sampled. Distribution B could be sampled 6 times before it is depleted.

Nesting

Nesting refers to compiled rows that have a parent. Nested rows are only eligible when their parents are also. See nesting for more details.

Functions

Sample, Bulk Sample (Unordered), and Bulk Sample (Ordered) can all be used to obtain random samples. All sample functions take a random number generator and return random item(s) (denoted by their indices) from the distribution according to their probabilities. Bulk Sample (Unordered) and Bulk Sample (Ordered) are more efficient versions of sample and should be preferred whenever possible.

Sample

Sample yields a single item index. For example, sampling Distribution A might yield '0'.

Bulk Sample (Unordered)

Bulk Sample (Unordered) yields an array of counts, with each index in the array corresponding to the item's index. For example, bulk sampling Distribution A with a Num Samples parameter of 5 might yield {1, 2, 2}. This means item 0 was sampled 1 time, item 1 was sampled twice, and item 2 was sampled twice.

Bulk Sample (Ordered)

Bulk Sample (Ordered) yields a sequence of item indices that were sampled, in the same order that they were sampled. Use this function when sampling order matters. For example, bulk sampling Distribution A 5 times might yield {1, 2, 0, 2, 1}, which would mean we sampled items 1, 2, 0, 2, 1 in that order.

caution

Bulk Sample (Ordered) can cause performance issues when the number of samples gets larger. It's recommended to keep the number of samples low (<=1000) when using this function. If you want to sample more than this, consider batching your calls by numbers less than 1,000 (e.g., if you want 10,000 samples, call the function 10 times and pass in 1,000 for sample count).

Masked Sample

Masked sampling applies a temporary mask to the distribution, then samples from it. The distribution's state is completely unchanged after masked sampling completes (including changes to counts for sampled rows).

Suppose we have this table:

Ref AssetWeightCountMaskM
AssetU100100.5
AssetV200102.0

If we were to masked sample by multiplying mask M, the table would look like this before sampling:

Ref AssetWeightCountMaskM
AssetU50100.5
AssetV400102.0

Suppose we sampled AssetV:

Ref AssetWeightCountMaskM
AssetU50100.5
AssetV40092.0

But after MaskedSample completes, it resets the table back to its original state:

Ref AssetWeightCountMaskM
AssetU100100.5
AssetV200102.0

Eligibility

An item in a distribution is eligible when it is able to be sampled. Similarly, an item is ineligible when it cannot be sampled. Eligibility conditions are defined by the distribution.

Pruning

Warnings caused by compiling invalid rows will Prune, or ignore, the rows from the built table. Suppose we have these tables:

Data Table Fruits
Row NameDisplay Name
AppleApple
BananaBanana
Loot Table C (Unlimited)
Row NameRef TableRef Row NameWeightRef ModeWeight Inherit Mode
XFruitsOrange100RowParent

Table C, Row X will be pruned because it doesn't reference a valid row from the Fruits table.

note

Pruned rows will always be listed as warnings in the Build Results tab.