aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-05-27 10:42:04 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-05-27 10:42:04 +0100
commitabf0dacb0b9c644383526ea88321e3861848a72f (patch)
treeb7cc1cb9c72f057f14d4ce641670934957bf9c68 /src
parent0e7dbaf43073f7e50186e05943604a6c6190ac3e (diff)
downloadrspamd-abf0dacb0b9c644383526ea88321e3861848a72f.tar.gz
rspamd-abf0dacb0b9c644383526ea88321e3861848a72f.zip
Try to avoid exp overflowing.
Diffstat (limited to 'src')
-rw-r--r--src/classifiers/bayes.c6
1 files 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 ++) {