[irstlm] 57/126: added supporting functions
Giulio Paci
giuliopaci-guest at moszumanska.debian.org
Tue May 17 07:46:45 UTC 2016
This is an automated email from the git hooks/post-receive script.
giuliopaci-guest pushed a commit to annotated tag adaptiveLM.v0.1
in repository irstlm.
commit 98e1b65b8e09fca4cc0871e15858514b2a3fddb5
Author: Nicola Bertoldi <bertoldi at fbk.eu>
Date: Wed Sep 9 17:05:58 2015 +0200
added supporting functions
---
src/util.cpp | 25 ++++++++++++++++++++++++-
src/util.h | 4 ++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/src/util.cpp b/src/util.cpp
index b25f3ea..665287e 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -380,9 +380,32 @@ float logsum(float a,float b){
else return b + logf(1+ expf(a-b));
}
+float log10sum(float a,float b){
+ if (b<a) return a + log10(1 + pow(10.0,(b-a)));
+ else return b + log10(1 + pow(10.0,(a-b)));
+}
+
double logsum(double a,double b){
if (b<a) return a + log(1 + exp(b-a));
- else return b + log(1+ exp(a-b));
+ else return b + log(1 + exp(a-b));
+}
+
+double log10sum(double a,double b){
+ if (b<a) return a + log10(1 + pow(10.0,(b-a)));
+ else return b + log10(1 + pow(10.0,(a-b)));
}
+double logistic_function(double x, double max, double steep)
+{
+ //domain: (-inf, +inf)
+ //image: [0,max)
+ //logistic_function(0.0,max,steep) = max/2
+ //lim_{x->+inf} logistic_function(x,max,steep) = max
+ //lim_{x->-inf} logistic_function(x,max,steep) = 0
+ //if steep1>steep2, then
+ // logistic_function(x,max,steep1) > logistic_function(x,max,steep2) if x>0
+ // logistic_function(x,max,steep1) < logistic_function(x,max,steep2) if x<0
+
+ return max/1+exp(-steep*x);
+}
diff --git a/src/util.h b/src/util.h
index 694a485..c49db09 100644
--- a/src/util.h
+++ b/src/util.h
@@ -104,7 +104,11 @@ extern const int tracelevel;
void MY_ASSERT(bool x);
float logsum(float a,float b);
+float log10sum(float a,float b);
double logsum(double a,double b);
+double log10sum(double a,double b);
+
+double logistic_function(double x, double max=1.0, double steep=1.0);
#endif
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/irstlm.git
More information about the debian-science-commits
mailing list