|
Boost Users : |
From: Kevin Martin (kev82_at_[hidden])
Date: 2008-05-03 08:12:06
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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net