[SciPy-Dev] special cephes versus cdflib

josef.pktd at gmail.com josef.pktd at gmail.com
Fri Oct 4 08:05:31 EDT 2013


On Fri, Oct 4, 2013 at 7:26 AM, Robert Kern <robert.kern at gmail.com> wrote:
> On Fri, Oct 4, 2013 at 1:44 AM, <josef.pktd at gmail.com> wrote:
>>
>> looking for the source for the cdf of the f-distribution
>>
>> it's in cephes not in cdflib
>> https://github.com/scipy/scipy/issues/2958#issuecomment-25668797
>> (after reading 3 fortran files to see where df>= 1 is imposed. It's
>> not, in cdflib)
>>
>>
>> Is there a pattern whether a `special` function is from cephes or cdflib?
>> If a function exists in cephes, is it used instead of the one from the
>> cdflib?
>
> I believe that CDFLIB was added to scipy later than cephes, so I expect that
> for most of the duplicates, the cephes one would be the one exposed in
> scipy.special. But there is no firm guideline here, since some of the CDFLIB
> versions may have been chosen for better behavior (like perhaps should be
> the case here). You always need to check generate_ufuncs.py to track down
> the implementation.
>
>> Is there a backdoor to access the (duplicate) cdflib function from python?
>
> No. You will have to wrap it yourself if you want it. Switching the
> implementation used in scipy.special.fdtr() should be straightforward if you
> want to do so. The wrapper cdff1_wrap() is there in cdf_wrappers.c, just
> commented out.

Thanks for the clarification.

In this case it's difficult to tell what might be better.
cephes uses `incbet` and
cdflib uses `bratio` for evaluating the incomplete beta function.
No idea which would be better over a larger range of values.

However, cum.f also swaps internally between calculating cdf and isf
which should give better values in the tails.

```
C     XX is such that the incomplete beta with parameters
C     DFD/2 and DFN/2 evaluated at XX is 1 - CUM or CCUM
C
C     YY is 1 - XX
C
C     Calculate the smaller of XX and YY accurately
```

Josef

>
> --
> Robert Kern
>
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
>



More information about the SciPy-Dev mailing list