Dominik - 5 months ago 39

Python Question

Is there a way to directly or indirectly call the Fortran routines that can be found here https://github.com/scipy/scipy/tree/master/scipy/special/cdflib and that are used by

`scipy.stats`

`numba`

`nopython`

Concretely, because

`scipy.stats.norm.cdf()`

`scipy.special.ndtr`

`numba`

Answer

I would take a look at rvlib, which uses Numba and CFFI to call RMath, which is the standalone C library that R uses to calculate statistical distributions. The functions it provides should be callable by Numba in `nopython`

mode. Take a look at the README for an example of the function that is equivalent to `scipy.stats.norm.cdf()`

If you're still interested in wrapping `cdflib`

yourself, I would recommend using CFFI. You'll have to build a C-interface for the functions you want. You might find this blog post that I wrote helpful in getting started:

https://www.continuum.io/blog/developer-blog/calling-c-libraries-numba-using-cffi