Overview
Alias table construction splits probabilities into small and large buckets and fills table columns with a primary outcome plus an alias. Sampling then needs one random column and one biased coin flip.
Preprocesses a discrete distribution so weighted samples can be drawn in constant time.
Compact metadata for implementation and discovery.
Alias table construction splits probabilities into small and large buckets and fills table columns with a primary outcome plus an alias. Sampling then needs one random column and one biased coin flip.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n)
Average
O(n log n)
Worst
O(n^2)
Space
O(n)
return column if u < probability[column] else alias[column]Uses one random column and one threshold comparison per draw.
Show precomputing probability and alias columns for constant-time sampling on a small weighted random sampling example.
Alias tables are a preprocessing tradeoff: fast draws for distributions that stay fixed.
What each reference supports for this entry.
Random variate generation reference for Alias Table Construction alias tables for constant-time discrete distribution sampling.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Alias tables are a fast method for repeated categorical or multinomial draws.
Inverse transform can sample from cumulative weights, while alias tables preprocess for constant-time draws.