scipy.special.erf#

scipy.special.erf(z, out=None) = <ufunc 'erf'>#

返回复数参数的误差函数。

其定义为 2/sqrt(pi)*integral(exp(-t**2), t=0..z)

参数:
xndarray

输入数组。

outndarray, optional

函数值的可选输出数组

返回:
resscalar or ndarray

给定点 x 处的误差函数值。

说明

单位正态分布的累积分布函数由 Phi(z) = 1/2[1 + erf(z/sqrt(2))] 给出。

erf 除了 NumPy 之外,还对 Python Array API Standard 兼容后端提供实验性支持。请考虑通过设置环境变量 SCIPY_ARRAY_API=1 并提供 CuPy、PyTorch、JAX 或 Dask 数组作为数组参数来测试这些功能。支持以下后端和设备(或其他功能)的组合。

CPU

GPU

NumPy

n/a

CuPy

n/a

PyTorch

JAX

Dask

n/a

有关更多信息,请参见 对数组 API 标准的支持

参考

[2]

Milton Abramowitz and Irene A. Stegun, eds. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. New York: Dover, 1972. http://www.math.sfu.ca/~cbm/aands/page_297.htm

[3]

Steven G. Johnson, Faddeeva W function implementation. http://ab-initio.mit.edu/Faddeeva

示例

>>> import numpy as np
>>> from scipy import special
>>> import matplotlib.pyplot as plt
>>> x = np.linspace(-3, 3)
>>> plt.plot(x, special.erf(x))
>>> plt.xlabel('$x$')
>>> plt.ylabel('$erf(x)$')
>>> plt.show()
../../_images/scipy-special-erf-1.png