From a2360c873ba8b72744e16752a067276a46d63645 Mon Sep 17 00:00:00 2001 From: graehl Date: Tue, 13 Jul 2010 02:54:53 +0000 Subject: random git-svn-id: https://ws10smt.googlecode.com/svn/trunk@230 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/sampler.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'decoder/sampler.h') 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 #include #include +#include #include "prob.h" @@ -78,6 +79,13 @@ struct RandomNumberGenerator { return (prob_t(this->next()) < a); } + RNG &gen() { return m_generator; } + typedef boost::variate_generator > 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; -- cgit v1.2.3