PyErf

A Pure-Python Error Function and Inverse Error Function Package

Travis-CI (Linux, Max) Latest PyPI version Python Wheels Supported Python Versions Documentation Status

pyerf is a pure-Python implementation of the error function and inverse error function using the same functions that SciPy uses (namely parts of the Cephes math library, cprob/ndtr.c and cprob/ndtri.c).

This is a useful package for when you need to calculate some error fuctions but you don’t want to install all of the SciPy/NumPy stuff.

Usage

You can import the module:

from pyerf import pyerf
pyerf.erfinv(0.5)         # 0.476936...
pyerf.erf(0.5)            # 0.5204998...
pyerf.erfc(0.5)           # 0.4795001...

or the package:

import pyerf
pyerf.erfinv(0.5)         # 0.476936...
pyerf.erf(0.5)            # 0.5204998...
pyerf.erfc(0.5)           # 0.4795001...

or only a specific function:

from pyerf import erfinv as inverse_error_function
inverse_error_function(0.5)       # 0.476936...

and lastly, you can even use import * (but that’s no longer considered very Pythonic as it pollutes the namespace):

from pyerf import *
pyerf.erfinv(0.5)         # 0.476936...
pyerf.erf(0.5)            # 0.5204998...
pyerf.erfc(0.5)           # 0.4795001...

Changelog

See CHANGELOG.md.

pyerf.pyerf

This is the main module for PyErf.

pyerf.pyerf.erfinv(z)[source]

Calculate the inverse error function at point z.

This is a direct port of the SciPy erfinv function, originally written in C.

Parameters:z (numeric) –
Returns:
Return type:float

References

Examples

>>> round(erfinv(0.1), 12)
0.088855990494
>>> round(erfinv(0.5), 12)
0.476936276204
>>> round(erfinv(-0.5), 12)
-0.476936276204
>>> round(erfinv(0.95), 12)
1.38590382435
>>> round(erf(erfinv(0.3)), 3)
0.3
>>> round(erfinv(erf(0.5)), 3)
0.5
>>> erfinv(0)
0
>>> erfinv(1)
inf
>>> erfinv(-1)
-inf

Indices and tables