[Python-3000] adding gamma and error functions to math module

Daniel Stutzbach daniel at stutzbachenterprises.com
Tue Jul 15 15:32:02 CEST 2008


On Tue, Jul 15, 2008 at 3:27 AM, Mark Dickinson <dickinsm at gmail.com> wrote:
> One reason is that they're probably not available on all platforms;
> these functions
> are part of the C99 standard, and not everyone has caught up with all the little
> details of C99 yet.  In particular, I wouldn't be surprised to learn
> that these functions
> still weren't available on Windows.  We had this problem when adding the
> inverse hyperbolic trig functions to Python 2.6.

Indeed, they aren't available on Windows (I just tested it via ctypes).

> Writing explicit code for these functions, for platforms whose libm doesn't
> support them, would be a fairly major task.  Stealing code (in an appropriately
> legal fashion) from somewhere else might work.

This would be great.  I need these functions pretty regularly (to
compute the CDF of normal and beta distributions), and it'd be
wonderful if I didn't have dive into C just to generate some values
for a plot.

I suggest using the versions from newlib's libm.  They contain
extensive comments explaining the math and have a generous license,
e.g.,:

http://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/src/newlib/libm/math/s_erf.c?rev=1.1.1.1&cvsroot=src

-- 
Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises LLC


More information about the Python-3000 mailing list