summaryrefslogtreecommitdiff
path: root/phrasinator
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-02-08 16:22:55 -0500
committerChris Dyer <cdyer@cs.cmu.edu>2012-02-08 16:22:55 -0500
commit648fd70ec05997003e801e113d825c84e55e01ca (patch)
treeee823da2a1b3d622e009a5e47846545c334b9220 /phrasinator
parentd91750f35d4d7edfc77a589ae92100d523068ad7 (diff)
move widely duplicated math functions into m.h header
Diffstat (limited to 'phrasinator')
-rw-r--r--phrasinator/gibbs_train_plm.cc8
1 files changed, 2 insertions, 6 deletions
diff --git a/phrasinator/gibbs_train_plm.cc b/phrasinator/gibbs_train_plm.cc
index 29b3d7ea..66b46011 100644
--- a/phrasinator/gibbs_train_plm.cc
+++ b/phrasinator/gibbs_train_plm.cc
@@ -8,6 +8,7 @@
#include "dict.h"
#include "sampler.h"
#include "ccrp.h"
+#include "m.h"
using namespace std;
using namespace std::tr1;
@@ -95,11 +96,6 @@ void ReadCorpus(const string& filename, vector<vector<int> >* c, set<int>* vocab
if (in != &cin) delete in;
}
-double log_poisson(unsigned x, const double& lambda) {
- assert(lambda > 0.0);
- return log(lambda) * x - lgamma(x + 1) - lambda;
-}
-
struct UniphraseLM {
UniphraseLM(const vector<vector<int> >& corpus,
const set<int>& vocab,
@@ -128,7 +124,7 @@ struct UniphraseLM {
double log_p0(const vector<int>& phrase) const {
double len_logprob;
if (use_poisson_)
- len_logprob = log_poisson(phrase.size(), 1.0);
+ len_logprob = Md::log_poisson(phrase.size(), 1.0);
else
len_logprob = log(1 - p_end_) * (phrase.size() -1) + log(p_end_);
return log(uniform_word_) * phrase.size() + len_logprob;