
3 May
2008
3 May
'08
12:12 p.m.
I'm looking for a random distribution which allows me to generate enums with specified probabilities. As a simple example I could have: //The enum. typedef enum {vt_car, vt_bus, vt_walk, vt_cycle} vehicle_types; //What I want to generate and the associated probabilities. boost::array<vehicle_types, 4> items = {vt_car, vt_bus, vt_walk, vt_cycle}; boost::array<double, 4> probabilities = {0.1, 0.2, 0.3, 0.4} //The random distribution. EnumGenerator eg(items, probabilities); //Generate some vehicles boost::mt19937 rng; eg(rng); eg(rng); eg(rng); I can't seem to find anything that does this. Is it there and I'm just missing it, or am I the only person who needs to do this? Thanks, Kevin Martin