scipy.special.erfinv#

scipy.special.erfinv(y, out=None) = <ufunc 'erfinv'>#

Inverse of the error function.

Computes the inverse of the error function.

In the complex domain, there is no unique complex number w satisfying erf(w)=z. This indicates a true inverse function would be multivalued. When the domain restricts to the real, -1 < x < 1, there is a unique real number satisfying erf(erfinv(x)) = x.

Parameters:
yndarray

Argument at which to evaluate. Domain: [-1, 1]

outndarray, optional

Optional output array for the function values

Returns:
erfinvscalar or ndarray

The inverse of erf of y, element-wise

See also

erf

Error function of a complex argument

erfc

Complementary error function, 1 - erf(x)

erfcinv

Inverse of the complementary error function

Notes

This function wraps the erf_inv routine from the Boost Math C++ library [1].

Array API Standard Support

erfinv has support for Python Array API Standard compatible backends in addition to NumPy. The following combinations of backend and device (or other capability) are supported.

Library

CPU

GPU

NumPy

n/a

CuPy

n/a

PyTorch

JAX

Dask

n/a

For the NumPy backend, this function supports all NumPy ufunc keyword arguments. Other backends may support out, but none of the other ufunc kwargs. out is typically supported for CuPy and PyTorch, but not currently in cases where SciPy relies on a generic Array API implementation or, for PyTorch on CPU, falls back to the NumPy backend. out is never supported for JAX because JAX arrays are immutable.

See Support for the array API standard for more information.

References

[1]

The Boost Developers. “Boost C++ Libraries”. https://www.boost.org/.

Examples

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy.special import erfinv, erf
>>> erfinv(0.5)
0.4769362762044699
>>> y = np.linspace(-1.0, 1.0, num=9)
>>> x = erfinv(y)
>>> x
array([       -inf, -0.81341985, -0.47693628, -0.22531206,  0.        ,
        0.22531206,  0.47693628,  0.81341985,         inf])

Verify that erf(erfinv(y)) is y.

>>> erf(x)
array([-1.  , -0.75, -0.5 , -0.25,  0.  ,  0.25,  0.5 ,  0.75,  1.  ])

Plot the function:

>>> y = np.linspace(-1, 1, 200)
>>> fig, ax = plt.subplots()
>>> ax.plot(y, erfinv(y))
>>> ax.grid(True)
>>> ax.set_xlabel('y')
>>> ax.set_title('erfinv(y)')
>>> plt.show()
../../_images/scipy-special-erfinv-1.png