[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gsl] bug in tdistinv.c and patch
From: |
Jason H. Stover |
Subject: |
[Bug-gsl] bug in tdistinv.c and patch |
Date: |
Sat, 25 Sep 2004 11:03:18 -0400 |
User-agent: |
Mutt/1.4.2.1i |
The following program will cause gsl_cdf_tdist_Pinv()
to attempt to invert the t distribution for invalid
arguments:
#include <stdio.h>
#include <gsl/gsl_cdf.h>
int main()
{
double p;
double x;
int df;
int j;
for(df = 1.0; df > -101.0; df--)
{
for (p = 1.01; p > -0.01; p -= .07)
{
x = gsl_cdf_tdist_Pinv (x, df);
printf ("%f\t%f\t%f\n", x, df, p);
}
}
exit(0);
}
The following patch for tdistinv.c fixes the problem:
? tdistinv.c.diff
? tdistinv.sav
Index: tdistinv.c
===================================================================
RCS file: /cvs/gsl/gsl/cdf/tdistinv.c,v
retrieving revision 1.2
diff -u -r1.2 tdistinv.c
--- tdistinv.c 26 Jul 2003 13:44:33 -0000 1.2
+++ tdistinv.c 25 Sep 2004 14:51:41 -0000
@@ -57,6 +57,18 @@
return GSL_NEGINF;
}
+ else if (P < 0.0)
+ {
+ GSL_ERROR ("P < 0.0", GSL_EDOM);
+ }
+ else if (P > 1.0)
+ {
+ GSL_ERROR ("P > 1.0", GSL_EDOM);
+ }
+ else if (nu <= 1.0 )
+ {
+ GSL_ERROR ("nu <= 1.0", GSL_EDOM );
+ }
if (nu == 1.0)
{
x = tan (M_PI * (P - 0.5));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug-gsl] bug in tdistinv.c and patch,
Jason H. Stover <=