In[21]: from scipy import special
In[22]: # Gamma函数 广义阶乘 generalized factorials 和相关函数
x [1, 5, 10]
print( gamma(x) , special.gamma(x))
print( ln|gamma(x)| , special.gammaln(x))
print( beta(x, 2) , special.beta(x, 2))
gamma(x) [ 1.00000000e 00 2.40000000e 01 3.62880000e 05]
ln|gamma(x)| [ 0. 3.17805383 12.80182748]
beta(x, 2) [ 0.5 0.03333333 0.00909091]
In[23]: # 误差函数 高斯积分
# 它的实现和它的逆实现
x np.array([0, 0.3, 0.7, 1.0])
print( erf(x) , special.erf(x))
print( erfc(x) , special.erfc(x))
print( erfinv(x) , special.erfinv(x))
erf(x) [ 0. 0.32862676 0.67780119 0.84270079]
erfc(x) [ 1. 0.67137324 0.32219881 0.15729921]
erfinv(x) [ 0. 0.27246271 0.73286908 inf]
12 高级的通用函数特性
In[25]: y np.zeros(10)
np.power(2, x, out y[::2])
print(y)
[ 1. 0. 2. 0. 4. 0. 8. 0. 16. 0.]