random number library | variate_generator | dynamic
2 Aug
2005
2 Aug
'05
10:57 p.m.
Hello: I am trying to use boost::variate_generator so that the generator and distribution can be set dynamically at run time. Currently, I am doing this using the following from http://www.boost.org/libs/random/random_speed.cpp Classes: RandomGenBase, DynamicRandomGenerator, GenericRandomGenerator Function: make_dynamic(URNG & rng, const Dist& d) Then I am able to do: boost::mt19937 rng; iosim::GenericRandomGenerator<int> g_int; g_int.set(iosim::make_dynamic(rng, boost::uniform_int<>(-2,4))); (use g_int()...) g_int.set(iosim::make_dynamic(rng, boost::geometric_distribution<>(0.5))); (use g_int()...) Is there a better way of doing this? Thanks.
7044
Age (days ago)
7044
Last active (days ago)
0 comments
1 participants
participants (1)
-
John Smith