This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Patch for histogram/stat2d.c
- From: Achim Gaedke <achim at zpr dot uni-koeln dot de>
- To: bjg at network-theory dot co dot uk, gsl discussion list <gsl-discuss at sources dot redhat dot com>
- Date: Tue, 5 Mar 2002 17:34:21 +0100 (MET)
- Subject: Patch for histogram/stat2d.c
Hi Brian and all the others!
I saw that you have annonuced gsl-1.1 on the homepage.
While installing it at my workplace, I found an error, that did not occure
before (I don't know why :-( ). It depends on a division by zero that
results in NaN. Please regard in this patch.
Index: stat2d.c
===================================================================
RCS file: /cvs/gsl/gsl/histogram/stat2d.c,v
retrieving revision 1.2
diff -r1.2 stat2d.c
87,88c87,90
< W += wi;
< wmean += (xi - wmean) * (wi / W);
---
> if (wi>0) {
> W += wi;
> wmean += (xi - wmean) * (wi / W);
> }
125,127c127,130
< W += wj;
< wmean += (yj - wmean) * (wj / W);
<
---
> if (wj>0) {
> W += wj;
> wmean += (yj - wmean) * (wj / W);
> }
164,165c167,170
< W += wi;
< wvariance += ((xi * xi) - wvariance) * (wi / W);
---
> if (wi>0) {
> W += wi;
> wvariance += ((xi * xi) - wvariance) * (wi / W);
> }
204,206c209,212
<
< W += wj;
< wvariance += ((yj * yj) - wvariance) * (wj / W);
---
> if (wj>0) {
> W += wj;
> wvariance += ((yj * yj) - wvariance) * (wj / W);
> }
Achim Gaedke, ZPR
Weyertal 80, 50931 Köln
Tel: +49 221 470 6021