scipy.special.expit

scipy.special.expit(x) = <ufunc 'expit'>

Expit(也称为Logistic Sigmoid)ufunc用于ndarray。

Exit函数,也称为Logistic Sigmoid函数,定义为 expit(x) = 1/(1+exp(-x)) 。它是logit函数的逆函数。

参数
xndarray

要将Exit应用到元素方面的ndarray。

退货
outndarray

与x形状相同的ndarray。其条目为 expit x的相应条目。

参见

logit

注意事项

作为ufunc expit,它接受许多可选的关键字参数。有关详细信息,请参阅 ufuncs

0.10.0 新版功能.

示例

>>> from scipy.special import expit, logit
>>> expit([-np.inf, -1.5, 0, 1.5, np.inf])
array([ 0.        ,  0.18242552,  0.5       ,  0.81757448,  1.        ])

logit 是与 expit

>>> logit(expit([-2.5, 0, 3.1, 5.0]))
array([-2.5,  0. ,  3.1,  5. ])

绘制x in的Exit(X)图 [-6, 6] :

>>> import matplotlib.pyplot as plt
>>> x = np.linspace(-6, 6, 121)
>>> y = expit(x)
>>> plt.plot(x, y)
>>> plt.grid()
>>> plt.xlim(-6, 6)
>>> plt.xlabel('x')
>>> plt.title('expit(x)')
>>> plt.show()
../../_images/scipy-special-expit-1.png