A Rust implementation of roulette wheel selection using the Alias Method. This can be used to simulate a loaded die and similar situations.
Initialization takes O(n) time; choosing a random element takes O(1) time. This is far faster than naive algorithms (the most common of which is commonly known as 'roulette wheel selection'). For an in-depth explanation of the algorithm, see http://www.keithschwarz.com/darts-dice-coins/.
This code was translated from http://www.keithschwarz.com/interesting/code/?dir=alias-method.
Example
let mut rng = thread_rng;
let roulette = new;
for _ in range