Skip to main content
`Ctrl`+`K`

# 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:
    y ndarray

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

    out ndarray, optional

      Optional output array for the function values

  Returns:
    erfinv scalar 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 experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable `SCIPY_ARRAY_API=1` and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. 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

  > 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()