From abf0dacb0b9c644383526ea88321e3861848a72f Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 27 May 2013 10:42:04 +0100 Subject: [PATCH] Try to avoid exp overflowing. --- src/classifiers/bayes.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/classifiers/bayes.c b/src/classifiers/bayes.c index 24174187f..77e02ea6b 100644 --- a/src/classifiers/bayes.c +++ b/src/classifiers/bayes.c @@ -111,7 +111,7 @@ bayes_learn_callback (gpointer key, gpointer value, gpointer data) static gdouble inv_chi_square (gdouble value, gint freedom_deg) { - gdouble prob, sum; + long double prob, sum; gint i; if ((freedom_deg & 1) != 0) { @@ -121,7 +121,7 @@ inv_chi_square (gdouble value, gint freedom_deg) value /= 2.; errno = 0; - prob = exp (-value); + prob = expl (-value); if (errno == ERANGE) { msg_err ("exp overflow"); return 0; @@ -288,7 +288,7 @@ bayes_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, final_prob = (s + 1 - h) / 2.; } - if (final_prob > 0 && fabs (final_prob - 0.5) > 0.1) { + if (final_prob > 0 && fabs (final_prob - 0.5) > 0.05) { sumbuf = memory_pool_alloc (task->task_pool, 32); for (i = 0; i < cnt; i ++) { -- 2.39.5