bug-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gsl] gsl_sf_beta_inc returns 0.0 all the time


From: Andrew Schein
Subject: [Bug-gsl] gsl_sf_beta_inc returns 0.0 all the time
Date: Tue, 21 Dec 2010 21:38:03 -0800

I first produced this error on Ubuntu gsl0-dev package 1.13+dfsg-1 on Ubuntu
10.04 (x86_64), but then downloaded gsl-1.13.tar.gz and compiled from source
(same machine).

Attached is a short program that attempts to reproduce a portion of the
incomplete beta curve for comparison against a plot shown in Numerical
Recipes in C++.  The numerical recipes plot varies x between (0,1) while
setting a=b=0.5.

#include <stdio.h>
#include <gsl/gsl_rng.h>

int main(int argc, char **argv) {
    long i;
    double x = 0.0;
    double a = 0.5;
    double b = 0.5;
    for (i=0; i < 10; i++) {
        x += 1.0/10.1;
        double from_gsl = gsl_sf_beta_inc(a,b,x);
        printf("a:%f b:%f x:%f betai(a,b,x):%f \n",a,b,x,from_gsl);
    }
    return 0;
}

The output is:

$ ./test_betai
a:0.500000 b:0.500000 x:0.099010 betai(a,b,x):0.000000
a:0.500000 b:0.500000 x:0.198020 betai(a,b,x):0.000000
a:0.500000 b:0.500000 x:0.297030 betai(a,b,x):0.000000
a:0.500000 b:0.500000 x:0.396040 betai(a,b,x):0.000000
a:0.500000 b:0.500000 x:0.495050 betai(a,b,x):0.000000
a:0.500000 b:0.500000 x:0.594059 betai(a,b,x):0.000000
a:0.500000 b:0.500000 x:0.693069 betai(a,b,x):0.000000
a:0.500000 b:0.500000 x:0.792079 betai(a,b,x):0.000000
a:0.500000 b:0.500000 x:0.891089 betai(a,b,x):0.000000
a:0.500000 b:0.500000 x:0.990099 betai(a,b,x):0.000000
$

Thanks,

Andy

-- 
Andrew I. Schein
www.andrewschein.com


reply via email to

[Prev in Thread] Current Thread [Next in Thread]