scipy.special.log1p#
- scipy.special.log1p(x, out=None) = <ufunc 'log1p'>#
计算 log(1 + x),当 x 接近于零时使用。
- 参数:
- xarray_like
实数或复数值输入。
- outndarray, 可选
函数结果的可选输出数组。
- 返回:
- 标量或 ndarray
log(1 + x)
的值。
示例
>>> import numpy as np >>> import scipy.special as sc
对于接近 0 的
x
,它比直接使用log(1 + x)
更准确。请注意,在下面的示例中,1 + 1e-17 == 1
为双精度。>>> sc.log1p(1e-17) 1e-17 >>> np.log(1 + 1e-17) 0.0