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 | a2360c873ba8b72744e16752a067276a46d63645 (patch) | |
tree | 5e2f52fbc61ae97e7694652395e64ed9302f43ee | |
parent | 3e6c1e09afe6224551945538a7bae1273ac7b26d (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; |