summaryrefslogtreecommitdiff
path: root/gi/pyp-topics/src/pyp.hh
diff options
context:
space:
mode:
authorphilblunsom@gmail.com <philblunsom@gmail.com@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-02 14:03:50 +0000
committerphilblunsom@gmail.com <philblunsom@gmail.com@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-02 14:03:50 +0000
commit23b3ac72093b642e9151deaa4864f5f084153e1b (patch)
tree02f06ee96207e0aed7d3a3cf696c0f9bddf93f5e /gi/pyp-topics/src/pyp.hh
parent187f6c1cd2849c2bbbdcf02e86f0ef591364620e (diff)
Small change to streamline sampling calculation.
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@102 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'gi/pyp-topics/src/pyp.hh')
-rw-r--r--gi/pyp-topics/src/pyp.hh11
1 files changed, 11 insertions, 0 deletions
diff --git a/gi/pyp-topics/src/pyp.hh b/gi/pyp-topics/src/pyp.hh
index 85076c98..80c79fe1 100644
--- a/gi/pyp-topics/src/pyp.hh
+++ b/gi/pyp-topics/src/pyp.hh
@@ -33,6 +33,7 @@ public:
double prob(Dish dish, double p0) const;
double prob(Dish dish, double dcd, double dca,
double dtd, double dta, double p0) const;
+ double unnormalised_prob(Dish dish, double p0) const;
int num_customers() const { return _total_customers; }
int num_types() const { return std::tr1::unordered_map<Dish,int>::size(); }
@@ -145,6 +146,16 @@ PYP<Dish,Hash>::prob(Dish dish, double p0) const
template <typename Dish, typename Hash>
double
+PYP<Dish,Hash>::unnormalised_prob(Dish dish, double p0) const
+{
+ int c = count(dish), t = num_tables(dish);
+ double r = num_tables() * _a + _b;
+ if (c > 0) return (c - _a * t + r * p0);
+ else return r * p0;
+}
+
+template <typename Dish, typename Hash>
+double
PYP<Dish,Hash>::prob(Dish dish, double dcd, double dca,
double dtd, double dta, double p0)
const