Overview
The Alias Method builds probability and alias tables so each draw chooses one column and then one of two outcomes.
Samples from a discrete weighted distribution in constant time after preprocessing.
Compact metadata for implementation and discovery.
The Alias Method builds probability and alias tables so each draw chooses one column and then one of two outcomes.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n)
Average
O(1) per sample after preprocessing
Worst
O(n)
Space
O(n)
scaled_weight_i = weight_i * n / sum(weights)Converts weights into table-column probabilities.
Show each table column split between a primary outcome and an alias outcome.
Weight changes require rebuilding or updating the tables.
What each reference supports for this entry.
Reference for constructing alias tables for constant-time discrete sampling.
Open sourceRandom variate generation reference for Alias Method's distribution-sampling mechanism and acceptance or transform rules.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Alias tables avoid a cumulative search for each discrete draw.
The alias method accelerates repeated draws from a discrete weighted distribution.