36 #ifndef RANDOMNUMBERGENERATORS_HPP_ 37 #define RANDOMNUMBERGENERATORS_HPP_ 39 #include <boost/shared_ptr.hpp> 40 #include <boost/version.hpp> 43 #if BOOST_VERSION < 106400 48 #include <boost/random.hpp> 50 #include <boost/serialization/split_member.hpp> 52 #include "SerializableSingleton.hpp" 93 #if BOOST_VERSION < 106400 // #2585 and #2893 101 friend class boost::serialization::access;
111 template <
class Archive>
112 void save(Archive& archive,
const unsigned int version)
const 114 std::stringstream rng_internals;
116 std::string rng_internals_string = rng_internals.str();
117 archive& rng_internals_string;
119 std::stringstream normal_internals;
120 #if BOOST_VERSION < 106400 // #2585 and #2893 123 const boost::normal_distribution<>& r_normal_dist = mGenerateStandardNormal.distribution();
125 normal_internals << r_normal_dist;
126 std::string normal_internals_string = normal_internals.str();
127 archive& normal_internals_string;
139 template <
class Archive>
140 void load(Archive& archive,
const unsigned int version)
142 std::string rng_internals_string;
143 archive& rng_internals_string;
144 std::stringstream rng_internals(rng_internals_string);
147 std::string normal_internals_string;
148 archive& normal_internals_string;
149 std::stringstream normal_internals(normal_internals_string);
150 normal_internals >> mGenerateStandardNormal.distribution();
152 BOOST_SERIALIZATION_SPLIT_MEMBER()
204 unsigned randMod(
unsigned base);
214 void Shuffle(std::vector<boost::shared_ptr<T> >& rValues)
216 unsigned num = rValues.size();
221 for (
unsigned end = num - 1; end > 0; end--)
225 boost::shared_ptr<T> temp = rValues[end];
226 rValues[end] = rValues[k];
240 void Shuffle(
unsigned num, std::vector<unsigned>& rValues);
261 void Reseed(
unsigned seed);
unsigned randMod(unsigned base)
void Reseed(unsigned seed)
boost::variate_generator< boost::mt19937 &, boost::random::normal_distribution_v165<> > mGenerateStandardNormal
static RandomNumberGenerator * mpInstance
double NormalRandomDeviate(double mean, double stdDev)
boost::variate_generator< boost::mt19937 &, boost::uniform_real<> > mGenerateUnitReal
void Shuffle(std::vector< boost::shared_ptr< T > > &rValues)
void save(Archive &archive, const unsigned int version) const
boost::mt19937 mMersenneTwisterGenerator
static RandomNumberGenerator * Instance()
double StandardNormalRandomDeviate()
double GammaRandomDeviate(double shape, double scale)
void load(Archive &archive, const unsigned int version)
double ExponentialRandomDeviate(double scale)