From: Bo Li Date: Fri, 6 Jun 2014 10:41:46 +0000 (-0500) Subject: Modified the use of uniform_01 X-Git-Url: https://git.donarmstrong.com/?p=rsem.git;a=commitdiff_plain;h=030b9364ddefc6d4ff17da9d8ae88fc3e4a973a5 Modified the use of uniform_01 --- diff --git a/EM.cpp b/EM.cpp index 4bda1d8..7016b89 100644 --- a/EM.cpp +++ b/EM.cpp @@ -506,7 +506,9 @@ void EM() { READ_INT_TYPE local_N; HIT_INT_TYPE fr, to, len, id; vector arr; - uniform01 rg(engine_type(hasSeed ? seed : time(NULL))); + engine_type engine(hasSeed ? seed : time(NULL)); + uniform_01_dist uniform_01; + uniform_01_generator rg(engine, uniform_01); if (verbose) cout<< "Begin to sample reads from their posteriors."<< endl; for (int i = 0; i < nThreads; i++) { diff --git a/Gibbs.cpp b/Gibbs.cpp index 7215c10..d5e0b9c 100644 --- a/Gibbs.cpp +++ b/Gibbs.cpp @@ -229,7 +229,7 @@ void* Gibbs(void* arg) { vector z, counts; vector arr; - uniform01 rg(*params->engine); + uniform_01_generator rg(*params->engine, uniform_01_dist()); // generate initial state sampleTheta(*params->engine, theta); diff --git a/sampling.h b/sampling.h index 8f80b72..7e445cf 100644 --- a/sampling.h +++ b/sampling.h @@ -10,10 +10,11 @@ #include "boost/random.hpp" typedef unsigned int seedType; -typedef boost::mt19937 engine_type; -typedef boost::gamma_distribution<> gamma_dist; -typedef boost::uniform_01 uniform01; -typedef boost::variate_generator gamma_generator; +typedef boost::random::mt19937 engine_type; +typedef boost::random::uniform_01<> uniform_01_dist; +typedef boost::random::gamma_distribution<> gamma_dist; +typedef boost::random::variate_generator uniform_01_generator; +typedef boost::random::variate_generator gamma_generator; class engineFactory { public: @@ -46,7 +47,7 @@ engine_type* engineFactory::seedEngine = NULL; // interval : [,) // random number should be in [0, arr[len - 1]) // If by chance arr[len - 1] == 0.0, one possibility is to sample uniformly from 0...len-1 -int sample(uniform01& rg, std::vector& arr, int len) { +int sample(uniform_01_generator& rg, std::vector& arr, int len) { int l, r, mid; double prb = rg() * arr[len - 1]; diff --git a/simul.h b/simul.h index 07c1c65..b62132a 100644 --- a/simul.h +++ b/simul.h @@ -8,8 +8,8 @@ class simul { public: - simul(unsigned int seed) : rg(boost::mt19937(seed)) { - } + simul(unsigned int seed) : engine(seed), rg(engine, boost::random::uniform_01<>()) { + } // interval : [,) // random number should be in [0, arr[len - 1]) @@ -35,7 +35,8 @@ public: double random() { return rg(); }; private: - boost::uniform_01 rg; + boost::random::mt19937 engine; + boost::random::variate_generator > rg; }; #endif /* SIMUL_H_ */