summaryrefslogtreecommitdiff
path: root/gi/pyp-topics/src/pyp-topics.hh
diff options
context:
space:
mode:
authorbothameister <bothameister@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-05 23:31:35 +0000
committerbothameister <bothameister@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-05 23:31:35 +0000
commite939fa567a3d33029b2f1084732b7472a48a9884 (patch)
tree7b3ee62272381463bd809b5139b109eadc82fcf9 /gi/pyp-topics/src/pyp-topics.hh
parent11deae81f9c6bf8f85a29dfdf8b1531d7c563ef8 (diff)
migrating away from mt19937ar to Boost.Random - separate RNG instances used in various places
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@146 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'gi/pyp-topics/src/pyp-topics.hh')
-rw-r--r--gi/pyp-topics/src/pyp-topics.hh23
1 files changed, 21 insertions, 2 deletions
diff --git a/gi/pyp-topics/src/pyp-topics.hh b/gi/pyp-topics/src/pyp-topics.hh
index 996ef4dd..9da49267 100644
--- a/gi/pyp-topics/src/pyp-topics.hh
+++ b/gi/pyp-topics/src/pyp-topics.hh
@@ -4,6 +4,11 @@
#include <vector>
#include <iostream>
#include <boost/ptr_container/ptr_vector.hpp>
+
+#include <boost/random/uniform_real.hpp>
+#include <boost/random/variate_generator.hpp>
+#include <boost/random/mersenne_twister.hpp>
+
#include "pyp.hh"
#include "corpus.hh"
@@ -15,9 +20,12 @@ public:
typedef double F;
public:
- PYPTopics(int num_topics, bool use_topic_pyp=false)
+ PYPTopics(int num_topics, bool use_topic_pyp=false, unsigned long seed = 0)
: m_num_topics(num_topics), m_word_pyps(1),
- m_topic_pyp(0.5,1.0), m_use_topic_pyp(use_topic_pyp) {}
+ m_topic_pyp(0.5,1.0,seed), m_use_topic_pyp(use_topic_pyp),
+ m_seed(seed),
+ uni_dist(0,1), rng(seed == 0 ? (unsigned long)this : seed),
+ rnd(rng, uni_dist) {}
void sample_corpus(const Corpus& corpus, int samples,
int freq_cutoff_start=0, int freq_cutoff_end=0,
@@ -60,6 +68,17 @@ private:
PYP<int> m_topic_pyp;
bool m_use_topic_pyp;
+ unsigned long m_seed;
+
+ typedef boost::mt19937 base_generator_type;
+ typedef boost::uniform_real<> uni_dist_type;
+ typedef boost::variate_generator<base_generator_type&, uni_dist_type> gen_type;
+
+ uni_dist_type uni_dist;
+ base_generator_type rng; //this gets the seed
+ gen_type rnd; //instantiate: rnd(rng, uni_dist)
+ //call: rnd() generates uniform on [0,1)
+
TermBackoffPtr m_backoff;
};