for gls users

Matthias Andree matthias.andree at gmx.de
Tue Aug 26 18:19:15 CEST 2003


Matthias Andree <matthias.andree at gmx.de> writes:

> Here's what I've developed after digging through several maths books,
> it's exact but may not be very fast. I've found it compares pretty well
> to dcdflib.

And here's the patch to integrate it and dump absolute and relative
error versus cdfchi (from DCDFLIB); this patch may complain about
offsets as David has cleaned up the #include lines in fisher.c since I
made the patch.

Index: fisher.c
===================================================================
RCS file: /cvsroot/bogofilter/bogofilter/src/fisher.c,v
retrieving revision 1.9
diff -u -r1.9 fisher.c
--- fisher.c	19 Jul 2003 11:20:30 -0000	1.9
+++ fisher.c	26 Aug 2003 16:16:18 -0000
@@ -16,6 +16,7 @@
 #include <dcdflib.h>
 
 #include "fisher.h"
+#include "macdfchi.h"
 
 #define	RF_DEBUG
 #undef	RF_DEBUG
@@ -72,14 +73,21 @@
 {
     int which=1;
     double p, q;
+    double q2;
     int status;
     double bound;
 
     /* pass in x, df; want p and q; return q */
     cdfchi(&which, &p, &q, &x, &df, &status, &bound);
 
+    q2 = macompcdfchi2(x, df);
+
+    fprintf(stderr, "x=%g, df=%g => prbf: %g, mycdf: %g, abs: %g, rel: %g%%\n",x,df,q, q2,
+	    fabs(q-q2), fabs(q-q2)/(max(fabs(q), fabs(q2)))*100);
+
     return(status==0 ? q : 1.0);
 }
+
 
 double fis_get_spamicity(size_t robn, FLOAT P, FLOAT Q )
 {


-- 
Matthias Andree




More information about the Bogofilter mailing list