[SciPy-dev] scipy.special.bdtrik bug (ticket #1076)

Robert Kern robert.kern@gmail....
Tue Dec 22 14:10:27 CST 2009


On Tue, Dec 22, 2009 at 14:01, Anne Archibald
<aarchiba@physics.mcgill.ca> wrote:
> Hi,
>
> I was recently doing some calculations with scipy.stats.binom().ppf
> and found a nasty bug ( http://projects.scipy.org/scipy/ticket/1076 ).
> If the binomial probability is tiny, totally wrong answers emerge. The
> problem turns out to be in the function scipy.special.bdtrik. There's
> no documentation anywhere about what this is supposed to do, but from
> context it's pretty clear it exists to calculate this value. It's a
> cephes function, and I got a little lost trying to track down its
> implementation. Maybe someone who's more familiar with cephes could
> point me to the code, and how to put it in __all__?

[~]$ cd svn/scipy/scipy/special
[special]$ grin -i bdtrik
./_cephesmodule.c:
  827 :         f = PyUFunc_FromFuncAndData(cephes3_functions,
cdfbin2_data, cephes_4_types, 2, 3, 1, PyUFunc_None, "bdtrik", "", 0);
  828 :         PyDict_SetItemString(dictionary, "bdtrik", f);
  902 :         f = PyUFunc_FromFuncAndData(cephes3_functions,
cdfnbn2_data, cephes_4_types, 2, 3, 1, PyUFunc_None, "nbdtrik", "",
0);
  903 :         PyDict_SetItemString(dictionary, "nbdtrik", f);
....

[special]$ grin cdfbin2
./_cephesmodule.c:
  208 : static void * cdfbin2_data[] = {(void *)cdfbin2_wrap, (void
*)cdfbin2_wrap};
  827 :         f = PyUFunc_FromFuncAndData(cephes3_functions,
cdfbin2_data, cephes_4_types, 2, 3, 1, PyUFunc_None, "bdtrik", "", 0);
./cdf_wrappers.c:
   93 : double cdfbin2_wrap(double p, double xn, double pr) {
./cdf_wrappers.h:
   18 : extern double cdfbin2_wrap(double p, double xn, double pr);

[special]$ less cdf_wrappers.c
# I see that cdfbin2_wrap() wraps the Fortran subroutine CDFBIN. This
tells me that it's from the cdflib collection of functions, not the
Cephes library itself.

[special]$ less cdflib/cdfbin.f

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco


More information about the SciPy-Dev mailing list