diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-13 02:54:53 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-13 02:54:53 +0000 |
commit | 2530464e1c2cc7eec9445b2f9b0ae90c59265f57 (patch) | |
tree | b6113b7f5e5181d80490ac9907fa685aae1cd4d8 | |
parent | 53dffbcd29cb8a91dccf6b0ffd7e4cb0a1d557a6 (diff) |
random
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@230 ec762483-ff6d-05da-a07a-a48fb63a330f
-rw-r--r-- | decoder/sampler.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/decoder/sampler.h b/decoder/sampler.h index cc13229b..5fef45d0 100644 --- a/decoder/sampler.h +++ b/decoder/sampler.h @@ -14,6 +14,7 @@ #include <boost/random/variate_generator.hpp> #include <boost/random/normal_distribution.hpp> #include <boost/random/poisson_distribution.hpp> +#include <boost/random/uniform_int.hpp> #include "prob.h" @@ -78,6 +79,13 @@ struct RandomNumberGenerator { return (prob_t(this->next()) < a); } + RNG &gen() { return m_generator; } + typedef boost::variate_generator<RNG&, boost::uniform_int<> > IntRNG; + IntRNG inclusive(int low,int high_incl) { + assert(high_incl>=low); + return IntRNG(m_generator,boost::uniform_int<>(low,high_incl)); + } + private: boost::uniform_real<> m_dist; RNG m_generator; |