SciPy-1-12-中文文档-十七-
SciPy 1.12 中文文档(十七)
scipy.special.wright_bessel
scipy.special.wright_bessel(a, b, x, out=None) = <ufunc 'wright_bessel'>
Wright 广义贝塞尔函数。
Wright 广义贝塞尔函数是整函数,定义为
[\Phi(a, b; x) = \sum_{k=0}^\infty \frac{x^k}{k! \Gamma(a k + b)}]
参见 [1]。
参数:
a浮点数数组
a >= 0
b浮点数数组
b >= 0
x浮点数数组
x >= 0
out,可选,ndarray
可选输出数组以获取函数结果
返回:
标量或者 ndarray
Wright 广义贝塞尔函数的值
注意事项
由于具有三个参数的函数的复杂性,仅实现非负参数。
参考文献
[1]
数学函数数字图书馆,10.46. dlmf.nist.gov/10.46.E1
示例
>>> from scipy.special import wright_bessel
>>> a, b, x = 1.5, 1.1, 2.5
>>> wright_bessel(a, b-1, x)
4.5314465939443025
现在,让我们验证这个关系
[\Phi(a, b-1; x) = a x \Phi(a, b+a; x) + (b-1) \Phi(a, b; x)]
>>> a * x * wright_bessel(a, b+a, x) + (b-1) * wright_bessel(a, b, x)
4.5314465939443025
scipy.special.lmbda
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.lmbda.html#scipy.special.lmbda
scipy.special.lmbda(v, x)
Jahnke-Emden Lambda 函数,即 Lambdav(x)。
此函数定义如[2]所示,
[\Lambda_v(x) = \Gamma(v+1) \frac{J_v(x)}{(x/2)^v},]
其中(\Gamma)为 Gamma 函数,(J_v)为第一类贝塞尔函数。
参数:
vfloat
Lambda 函数的阶数
xfloat
函数及其导数计算的值。
返回值:
vlndarray
Lambda_vi(x)的值,对于 vi=v-int(v),vi=1+v-int(v),…,vi=v。
dlndarray
Lambda_vi’(x)的导数,对于 vi=v-int(v),vi=1+v-int(v),…,vi=v。
参考文献:
[1]
Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
[2]
Jahnke, E. and Emde, F. “Tables of Functions with Formulae and Curves” (4th ed.), Dover, 1945
scipy.special.jnjnp_zeros
scipy.special.jnjnp_zeros(nt)
计算整数阶贝塞尔函数Jn
和Jn'
的零点。
结果按零点的大小排序。
参数:
nt 整数
计算的零点数(<=1200)
返回:
zo[l-1] 数组
Jn(x)
和Jn'(x)
的第 l 个零点的值。长度为nt。
n[l-1] 数组
Jn(x)
或Jn'(x)
的顺序,与第 l 个零点相关。长度为nt。
m[l-1] 数组
Jn(x)
或Jn'(x)
的零点的序号,与第 l 个零点相关。长度为nt。
t[l-1] 数组
如果 zo 的第 l 个零点是Jn(x)
的零点,则为 0;如果是Jn'(x)
的零点,则为 1。长度为nt。
另见
jn_zeros
,jnp_zeros
以获取分离的零点数组。
参考文献
[1]
张, 善杰 和 金, 建明. “特殊函数的计算”, 约翰·威利和儿子, 1996 年, 第五章. people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
scipy.special.jnyn_zeros
scipy.special.jnyn_zeros(n, nt)
计算贝塞尔函数 Jn(x)、Jn’(x)、Yn(x)和 Yn’(x)的nt个零点。
返回长度为nt的 4 个数组,分别对应 Jn(x)、Jn’(x)、Yn(x)和 Yn’(x)的前nt个零点,零点按升序返回。
参数:
nint
贝塞尔函数的阶数
ntint
需要计算的零点数(<=1200)
返回:
Jnndarray
第一nt个 Jn 的零点
Jnpndarray
第一nt个 Jn’的零点
Ynndarray
第一nt个 Yn 的零点
Ynpndarray
第一nt个 Yn’的零点
另请参阅
jn_zeros
, jnp_zeros
, yn_zeros
, ynp_zeros
参考文献
[1]
张善杰和金建明。“特殊函数的计算”,John Wiley and Sons,1996 年,第五章。people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
示例
计算(J_1)、(J_1')、(Y_1)和(Y_1')的前三个根。
>>> from scipy.special import jnyn_zeros
>>> jn_roots, jnp_roots, yn_roots, ynp_roots = jnyn_zeros(1, 3)
>>> jn_roots, yn_roots
(array([ 3.83170597, 7.01558667, 10.17346814]),
array([2.19714133, 5.42968104, 8.59600587]))
绘制(J_1)、(J_1')、(Y_1)、(Y_1')及其根。
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy.special import jnyn_zeros, jvp, jn, yvp, yn
>>> jn_roots, jnp_roots, yn_roots, ynp_roots = jnyn_zeros(1, 3)
>>> fig, ax = plt.subplots()
>>> xmax= 11
>>> x = np.linspace(0, xmax)
>>> x[0] += 1e-15
>>> ax.plot(x, jn(1, x), label=r"$J_1$", c='r')
>>> ax.plot(x, jvp(1, x, 1), label=r"$J_1'$", c='b')
>>> ax.plot(x, yn(1, x), label=r"$Y_1$", c='y')
>>> ax.plot(x, yvp(1, x, 1), label=r"$Y_1'$", c='c')
>>> zeros = np.zeros((3, ))
>>> ax.scatter(jn_roots, zeros, s=30, c='r', zorder=5,
... label=r"$J_1$ roots")
>>> ax.scatter(jnp_roots, zeros, s=30, c='b', zorder=5,
... label=r"$J_1'$ roots")
>>> ax.scatter(yn_roots, zeros, s=30, c='y', zorder=5,
... label=r"$Y_1$ roots")
>>> ax.scatter(ynp_roots, zeros, s=30, c='c', zorder=5,
... label=r"$Y_1'$ roots")
>>> ax.hlines(0, 0, xmax, color='k')
>>> ax.set_ylim(-0.6, 0.6)
>>> ax.set_xlim(0, xmax)
>>> ax.legend(ncol=2, bbox_to_anchor=(1., 0.75))
>>> plt.tight_layout()
>>> plt.show()
scipy.special.jn_zeros
scipy.special.jn_zeros(n, nt)
计算整数阶 Bessel 函数 Jn 的零点。
在区间 ((0, \infty)) 上计算 Bessel 函数 (J_n(x)) 的前 nt 个零点。这些零点按升序返回。请注意,此区间不包括对于 (n > 0) 存在于 (x = 0) 处的零点。
参数:
n int
Bessel 函数的阶数
nt int
要返回的零点数量
返回:
ndarray
Bessel 函数的前 nt 个零点。
另见
jv
第一类实阶 Bessel 函数
jnp_zeros
(Jn') 的零点
参考文献
[1]
张善杰和金建明著。“特殊函数的计算”,约翰·威利与儿子,1996 年,第五章。people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
示例
计算 (J_3) 的前四个正根。
>>> from scipy.special import jn_zeros
>>> jn_zeros(3, 4)
array([ 6.3801619 , 9.76102313, 13.01520072, 16.22346616])
绘制 (J_3) 及其前四个正根。请注意,位于 0 处的根不由 jn_zeros
返回。
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy.special import jn, jn_zeros
>>> j3_roots = jn_zeros(3, 4)
>>> xmax = 18
>>> xmin = -1
>>> x = np.linspace(xmin, xmax, 500)
>>> fig, ax = plt.subplots()
>>> ax.plot(x, jn(3, x), label=r'$J_3$')
>>> ax.scatter(j3_roots, np.zeros((4, )), s=30, c='r',
... label=r"$J_3$_Zeros", zorder=5)
>>> ax.scatter(0, 0, s=30, c='k',
... label=r"Root at 0", zorder=5)
>>> ax.hlines(0, 0, xmax, color='k')
>>> ax.set_xlim(xmin, xmax)
>>> plt.legend()
>>> plt.show()
scipy.special.jnp_zeros
scipy.special.jnp_zeros(n, nt)
计算整数阶 Bessel 函数导数 (Jn') 的零点。
在区间 ((0, \infty)) 上计算函数 (J_n'(x)) 的 nt 个零点。零点按升序返回。注意,此区间不包括 (x = 0) 处 (n > 1) 时存在的零点。
参数:
nint
Bessel 函数的阶数
ntint
要返回的零点数
返回值:
ndarray
First nt zeros of the Bessel function.
另请参阅
jvp
整数阶贝塞尔函数的导数
jv
浮点阶贝塞尔函数的第一类
参考文献
[1]
Zhang, Shanjie 和 Jin, Jianming. “特殊函数的计算”, John Wiley and Sons, 1996, 第五章。people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
示例
计算 (J_2') 的前四个根。
>>> from scipy.special import jnp_zeros
>>> jnp_zeros(2, 4)
array([ 3.05423693, 6.70613319, 9.96946782, 13.17037086])
如 jnp_zeros
返回 (J_n') 的根,可用于计算 (J_n) 的峰值位置。绘制 (J_2)、(J_2') 及 (J_2') 的根的位置。
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy.special import jn, jnp_zeros, jvp
>>> j2_roots = jnp_zeros(2, 4)
>>> xmax = 15
>>> x = np.linspace(0, xmax, 500)
>>> fig, ax = plt.subplots()
>>> ax.plot(x, jn(2, x), label=r'$J_2$')
>>> ax.plot(x, jvp(2, x, 1), label=r"$J_2'$")
>>> ax.hlines(0, 0, xmax, color='k')
>>> ax.scatter(j2_roots, np.zeros((4, )), s=30, c='r',
... label=r"Roots of $J_2'$", zorder=5)
>>> ax.set_ylim(-0.4, 0.8)
>>> ax.set_xlim(0, xmax)
>>> plt.legend()
>>> plt.show()
scipy.special.yn_zeros
scipy.special.yn_zeros(n, nt)
计算整数阶贝塞尔函数 ( Y_n(x) ) 的零点。
计算 nt 个函数 ( Y_n(x) ) 在区间 ((0, \infty)) 上的零点。这些零点按升序返回。
参数:
n整数
贝塞尔函数的阶数
nt整数
要返回的零点数
返回:
ndarray
贝塞尔函数的前 nt 个零点。
另请参阅
yn
整数阶贝塞尔函数的第二类函数
yv
实数阶贝塞尔函数的第二类函数
参考文献
[1]
张, 善杰 和 金, 建明. “特殊函数的计算”, 约翰·威利与儿子公司, 1996 年, 第五章. people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
示例
计算 ( Y_2 ) 的前四个根。
>>> from scipy.special import yn_zeros
>>> yn_zeros(2, 4)
array([ 3.38424177, 6.79380751, 10.02347798, 13.20998671])
绘制 ( Y_2 ) 及其前四个根。
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy.special import yn, yn_zeros
>>> xmin = 2
>>> xmax = 15
>>> x = np.linspace(xmin, xmax, 500)
>>> fig, ax = plt.subplots()
>>> ax.hlines(0, xmin, xmax, color='k')
>>> ax.plot(x, yn(2, x), label=r'$Y_2$')
>>> ax.scatter(yn_zeros(2, 4), np.zeros((4, )), s=30, c='r',
... label='Roots', zorder=5)
>>> ax.set_ylim(-0.4, 0.4)
>>> ax.set_xlim(xmin, xmax)
>>> plt.legend()
>>> plt.show()
scipy.special.ynp_zeros
scipy.special.ynp_zeros(n, nt)
计算整数阶贝塞尔函数导数 (Yn'(x)) 的零点。
在区间 ((0, \infty)) 上计算 nt 个函数 (Y_n'(x)) 的零点。返回的零点按升序排列。
参数:
nint
贝塞尔函数的阶数
ntint
要返回的零点数
返回:
ndarray
第一个 nt 个贝塞尔函数导数的零点。
另请参见
yvp
参考文献
[1]
张善杰和金建明。“特殊函数的计算”,John Wiley and Sons,1996 年,第五章。people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
示例
计算阶数为 0 的贝塞尔函数第一导数的前四个根 (Y_0')。
>>> from scipy.special import ynp_zeros
>>> ynp_zeros(0, 4)
array([ 2.19714133, 5.42968104, 8.59600587, 11.74915483])
绘制 (Y_0)、(Y_0') 并视觉确认 (Y_0') 的根位于 (Y_0) 的局部极值点。
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy.special import yn, ynp_zeros, yvp
>>> zeros = ynp_zeros(0, 4)
>>> xmax = 13
>>> x = np.linspace(0, xmax, 500)
>>> fig, ax = plt.subplots()
>>> ax.plot(x, yn(0, x), label=r'$Y_0$')
>>> ax.plot(x, yvp(0, x, 1), label=r"$Y_0'$")
>>> ax.scatter(zeros, np.zeros((4, )), s=30, c='r',
... label=r"Roots of $Y_0'$", zorder=5)
>>> for root in zeros:
... y0_extremum = yn(0, root)
... lower = min(0, y0_extremum)
... upper = max(0, y0_extremum)
... ax.vlines(root, lower, upper, color='r')
>>> ax.hlines(0, 0, xmax, color='k')
>>> ax.set_ylim(-0.6, 0.6)
>>> ax.set_xlim(0, xmax)
>>> plt.legend()
>>> plt.show()
scipy.special.y0_zeros
scipy.special.y0_zeros(nt, complex=False)
计算贝塞尔函数(Y0(z))的 nt 个零点,以及每个零点处的导数。
导数由每个零点(z0)处的(Y0’(z0) = -Y1(z0))给出。
参数:
ntint
返回零点的数量
complexbool,默认为 False
将其设置为 False 以仅返回实根;将其设置为 True 以仅返回具有负实部和正虚部的复根。请注意,后者的复共轭也是函数的零点,但此例程不返回它们。
返回:
z0nndarray
第 n 个(Y0(z))的零点位置
y0pz0nndarray
第 n 个零点处的导数(Y0’(z0))
参考资料
[1]
张善杰和金建明。“特殊函数的计算”,John Wiley and Sons,1996 年,第五章。people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
示例
计算(Y_0)的前 4 个实根及其根处的导数:
>>> import numpy as np
>>> from scipy.special import y0_zeros
>>> zeros, grads = y0_zeros(4)
>>> with np.printoptions(precision=5):
... print(f"Roots: {zeros}")
... print(f"Gradients: {grads}")
Roots: [ 0.89358+0.j 3.95768+0.j 7.08605+0.j 10.22235+0.j]
Gradients: [-0.87942+0.j 0.40254+0.j -0.3001 +0.j 0.2497 +0.j]
绘制(Y_0)的实部和前四个计算得到的根。
>>> import matplotlib.pyplot as plt
>>> from scipy.special import y0
>>> xmin = 0
>>> xmax = 11
>>> x = np.linspace(xmin, xmax, 500)
>>> fig, ax = plt.subplots()
>>> ax.hlines(0, xmin, xmax, color='k')
>>> ax.plot(x, y0(x), label=r'$Y_0$')
>>> zeros, grads = y0_zeros(4)
>>> ax.scatter(zeros.real, np.zeros((4, )), s=30, c='r',
... label=r'$Y_0$_zeros', zorder=5)
>>> ax.set_ylim(-0.5, 0.6)
>>> ax.set_xlim(xmin, xmax)
>>> plt.legend(ncol=2)
>>> plt.show()
通过设置complex=True
计算(Y_0)的前 4 个复根及其根处的导数:
>>> y0_zeros(4, True)
(array([ -2.40301663+0.53988231j, -5.5198767 +0.54718001j,
-8.6536724 +0.54841207j, -11.79151203+0.54881912j]),
array([ 0.10074769-0.88196771j, -0.02924642+0.5871695j ,
0.01490806-0.46945875j, -0.00937368+0.40230454j]))
scipy.special.y1_zeros
scipy.special.y1_zeros(nt, complex=False)
计算贝塞尔函数 (Y1(z)) 的 nt 个零点及每个零点处的导数。
每个零点 z1 处的导数由 Y1’(z1) = Y0(z1) 给出。
参数:
ntint
要返回的零的数量
complexbool,默认为 False
将其设置为 False 以仅返回实零点;将其设置为 True 以仅返回具有负实部和正虚部的复零点。请注意,后者的复共轭也是函数的零点,但不会由此程序返回。
返回:
z1nndarray
第 n 个(Y1(z))的零点位置
y1pz1nndarray
第 n 个零点处的导数值 Y1’(z1)
参考文献
[1]
张, 珊杰 和 金, 建明。“特殊函数的计算”,约翰·威利和儿子出版社,1996 年,第五章。people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
示例
计算(Y_1)的前 4 个实根及其在根处的导数:
>>> import numpy as np
>>> from scipy.special import y1_zeros
>>> zeros, grads = y1_zeros(4)
>>> with np.printoptions(precision=5):
... print(f"Roots: {zeros}")
... print(f"Gradients: {grads}")
Roots: [ 2.19714+0.j 5.42968+0.j 8.59601+0.j 11.74915+0.j]
Gradients: [ 0.52079+0.j -0.34032+0.j 0.27146+0.j -0.23246+0.j]
提取实部:
>>> realzeros = zeros.real
>>> realzeros
array([ 2.19714133, 5.42968104, 8.59600587, 11.74915483])
绘制 (Y_1) 和前四个计算出的根。
>>> import matplotlib.pyplot as plt
>>> from scipy.special import y1
>>> xmin = 0
>>> xmax = 13
>>> x = np.linspace(xmin, xmax, 500)
>>> zeros, grads = y1_zeros(4)
>>> fig, ax = plt.subplots()
>>> ax.hlines(0, xmin, xmax, color='k')
>>> ax.plot(x, y1(x), label=r'$Y_1$')
>>> ax.scatter(zeros.real, np.zeros((4, )), s=30, c='r',
... label=r'$Y_1$_zeros', zorder=5)
>>> ax.set_ylim(-0.5, 0.5)
>>> ax.set_xlim(xmin, xmax)
>>> plt.legend()
>>> plt.show()
通过设置 complex=True
计算(Y_1)的前 4 个复根及其在根处的导数:
>>> y1_zeros(4, True)
(array([ -0.50274327+0.78624371j, -3.83353519+0.56235654j,
-7.01590368+0.55339305j, -10.17357383+0.55127339j]),
array([-0.45952768+1.31710194j, 0.04830191-0.69251288j,
-0.02012695+0.51864253j, 0.011614 -0.43203296j]))
scipy.special.y1p_zeros
scipy.special.y1p_zeros(nt, complex=False)
计算贝塞尔导数 Y1’(z)的 nt 个零点,并计算每个零点处的值。
值由 Y1(z1)在每个 Y1’(z1)=0 的 z1 处给出。
参数:
nt int
要返回的零点数
复杂bool,默认为 False
设为 False 以仅返回实部为零的零点;设为 True 以仅返回具有负实部和正虚部的复零点。请注意,后者的复共轭也是该函数的零点,但不会被此例程返回。
返回:
z1pn ndarray
第 n 个 Y1’(z)的零点的位置
y1z1pn ndarray
第 n 个零点处的导数 Y1(z1)的值
参考文献
[1]
张, 善杰 和 金, 建明. “特殊函数的计算”, 约翰威利和儿子, 1996, 第五章. people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
示例
计算(Y_1')的前四个根和这些根处的(Y_1)的值。
>>> import numpy as np
>>> from scipy.special import y1p_zeros
>>> y1grad_roots, y1_values = y1p_zeros(4)
>>> with np.printoptions(precision=5):
... print(f"Y1' Roots: {y1grad_roots}")
... print(f"Y1 values: {y1_values}")
Y1' Roots: [ 3.68302+0.j 6.9415 +0.j 10.1234 +0.j 13.28576+0.j]
Y1 values: [ 0.41673+0.j -0.30317+0.j 0.25091+0.j -0.21897+0.j]
y1p_zeros
可用于直接计算(Y_1)的极值点。这里我们绘制了(Y_1)和前四个极值点。
>>> import matplotlib.pyplot as plt
>>> from scipy.special import y1, yvp
>>> y1_roots, y1_values_at_roots = y1p_zeros(4)
>>> real_roots = y1_roots.real
>>> xmax = 15
>>> x = np.linspace(0, xmax, 500)
>>> x[0] += 1e-15
>>> fig, ax = plt.subplots()
>>> ax.plot(x, y1(x), label=r'$Y_1$')
>>> ax.plot(x, yvp(1, x, 1), label=r"$Y_1'$")
>>> ax.scatter(real_roots, np.zeros((4, )), s=30, c='r',
... label=r"Roots of $Y_1'$", zorder=5)
>>> ax.scatter(real_roots, y1_values_at_roots.real, s=30, c='k',
... label=r"Extrema of $Y_1$", zorder=5)
>>> ax.hlines(0, 0, xmax, color='k')
>>> ax.set_ylim(-0.5, 0.5)
>>> ax.set_xlim(0, xmax)
>>> ax.legend(ncol=2, bbox_to_anchor=(1., 0.75))
>>> plt.tight_layout()
>>> plt.show()
scipy.special.j0
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.j0.html#scipy.special.j0
scipy.special.j0(x, out=None) = <ufunc 'j0'>
零阶第一类贝塞尔函数。
参数:
x 类似数组
参数(浮点数)。
out ndarray, 可选
可选的函数值输出数组
返回:
J标量或 ndarray
x 处零阶第一类贝塞尔函数的值。
参见
jv
实数阶贝塞尔函数和复数参数的贝塞尔函数。
spherical_jn
球面贝塞尔函数。
注释
将域分为区间[0, 5]和(5, 无穷大)。在第一个区间内使用以下有理近似:
[J_0(x) \approx (w - r_1²)(w - r_2²) \frac{P_3(w)}{Q_8(w)},]
其中 (w = x²),(r_1)、(r_2) 是 (J_0) 的零点,(P_3) 和 (Q_8) 是分别为 3 和 8 次的多项式。
在第二区间内,使用 Hankel 渐近展开,其中包括两个 6/6 和 7/7 次有理函数。
此函数是 Cephes 的[1]例程j0
的包装。请勿与球面贝塞尔函数混淆(参见spherical_jn
)。
参考资料
[1]
Cephes 数学函数库,www.netlib.org/cephes/
示例
计算单点函数:
>>> from scipy.special import j0
>>> j0(1.)
0.7651976865579665
计算多点函数:
>>> import numpy as np
>>> j0(np.array([-2., 0., 4.]))
array([ 0.22389078, 1\. , -0.39714981])
绘制从-20 到 20 的函数图像。
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> x = np.linspace(-20., 20., 1000)
>>> y = j0(x)
>>> ax.plot(x, y)
>>> plt.show()
scipy.special.j1
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.j1.html#scipy.special.j1
scipy.special.j1(x, out=None) = <ufunc 'j1'>
一阶贝塞尔函数的示例。
参数:
xarray_like
参数(浮点数)。
outndarray,可选
函数值的可选输出数组
返回:
J标量或 ndarray
在x处一阶贝塞尔函数的值。
参见
jv
一阶贝塞尔函数
spherical_jn
球形贝塞尔函数。
注释
该域被分为区间[0, 8]和(8, 无穷大)。在第一个区间中使用 24 项切比雪夫展开式。在第二个区间中,采用两个 5/5 次有理函数的渐近三角表示法。
此函数是 Cephes [1]例程j1
的包装器。请不要将其与球形贝塞尔函数混淆(请参见spherical_jn
)。
参考文献
[1]
Cephes 数学函数库,www.netlib.org/cephes/
示例
在一个点计算函数:
>>> from scipy.special import j1
>>> j1(1.)
0.44005058574493355
在多个点计算函数:
>>> import numpy as np
>>> j1(np.array([-2., 0., 4.]))
array([-0.57672481, 0\. , -0.06604333])
绘制从-20 到 20 的函数图。
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> x = np.linspace(-20., 20., 1000)
>>> y = j1(x)
>>> ax.plot(x, y)
>>> plt.show()
scipy.special.y0
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.y0.html#scipy.special.y0
scipy.special.y0(x, out=None) = <ufunc 'y0'>
零阶第二类贝塞尔函数。
参数:
xarray_like
参数(浮点数)。
outndarray,可选
可选的输出数组用于函数结果
返回:
Y标量或 ndarray
零阶第二类贝塞尔函数在x处的值。
另请参见
j0
零阶第一类贝塞尔函数
yv
第一类贝塞尔函数
注意事项
域被分为区间[0, 5]和(5, 无穷大)。在第一个区间中,使用有理逼近(R(x))计算,
[Y_0(x) = R(x) + \frac{2 \log(x) J_0(x)}{\pi},]
其中(J_0)是零阶第一类贝塞尔函数。
在第二个区间中,使用 6/6 和 7/7 阶有理函数的 Hankel 渐近展开。
此函数是 Cephes 库[1]中y0
的封装。
参考文献
[1]
Cephes 数学函数库,www.netlib.org/cephes/
示例
计算一个点上的函数:
>>> from scipy.special import y0
>>> y0(1.)
0.08825696421567697
在几个点上计算:
>>> import numpy as np
>>> y0(np.array([0.5, 2., 3.]))
array([-0.44451873, 0.51037567, 0.37685001])
从 0 到 10 绘制函数。
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> x = np.linspace(0., 10., 1000)
>>> y = y0(x)
>>> ax.plot(x, y)
>>> plt.show()
scipy.special.y1
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.y1.html#scipy.special.y1
scipy.special.y1(x, out=None) = <ufunc 'y1'>
第二类贝塞尔函数,阶数为 1。
参数:
xarray_like
参数(浮点数)。
outndarray,可选
函数结果的可选输出数组
返回:
Y标量或 ndarray
在x处阶数为 1 的第二类贝塞尔函数值。
另请参阅
j1
第一类贝塞尔函数,阶数为 1
yn
第二类贝塞尔函数
yv
第二类贝塞尔函数
注意事项
域被分成区间[0, 8]和(8, 无穷大)。在第一个区间使用 25 项切比雪夫展开,计算(J_1)(第一类贝塞尔函数)是必需的。在第二个区间,使用两个 5/5 次有理函数的渐近三角函数表示。
此函数是 Cephes [1]例程的包装 y1
。
参考资料
[1]
Cephes 数学函数库,www.netlib.org/cephes/
示例
在一个点计算函数:
>>> from scipy.special import y1
>>> y1(1.)
-0.7812128213002888
在多个点计算:
>>> import numpy as np
>>> y1(np.array([0.5, 2., 3.]))
array([-1.47147239, -0.10703243, 0.32467442])
绘制从 0 到 10 的函数图像。
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> x = np.linspace(0., 10., 1000)
>>> y = y1(x)
>>> ax.plot(x, y)
>>> plt.show()
scipy.special.i0
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.i0.html#scipy.special.i0
scipy.special.i0(x, out=None) = <ufunc 'i0'>
零阶修正贝塞尔函数。
定义如下,
[I_0(x) = \sum_{k=0}^\infty \frac{(x²/4)^k}{(k!)²} = J_0(\imath x),]
其中 (J_0) 是零阶第一类贝塞尔函数。
参数:
x:array_like
参数(浮点数)
out:ndarray,可选
可选的输出数组用于函数值
返回:
I:标量或者 ndarray
在x处的零阶修正贝塞尔函数的值。
请参见
iv
任意阶数的修正贝塞尔函数
i0e
指数尺度的零阶修正贝塞尔函数
注意事项
区间被分为两个部分[0, 8]和(8, 无穷大)。在每个区间中使用切比雪夫多项式展开。
此函数是 Cephes 的[1]例程i0
的包装器。
参考文献
[1]
Cephes 数学函数库,www.netlib.org/cephes/
示例
在一个点计算函数:
>>> from scipy.special import i0
>>> i0(1.)
1.2660658777520082
在几个点计算:
>>> import numpy as np
>>> i0(np.array([-2., 0., 3.5]))
array([2.2795853 , 1\. , 7.37820343])
在区间 -10 到 10 绘制函数。
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> x = np.linspace(-10., 10., 1000)
>>> y = i0(x)
>>> ax.plot(x, y)
>>> plt.show()
scipy.special.i0e
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.i0e.html#scipy.special.i0e
scipy.special.i0e(x, out=None) = <ufunc 'i0e'>
阶数为 0 的指数尺度修改贝塞尔函数。
定义如下:
i0e(x) = exp(-abs(x)) * i0(x).
参数:
xarray_like
参数(浮点数)
outndarray,可选
可选输出数组的函数值
返回:
Iscalar or ndarray
x 的指数尺度修改贝塞尔函数阶数为 0 的值。
另请参见
第一类修正贝塞尔函数
阶数为 0 的修正贝塞尔函数
注意事项
将范围分为两个区间 [0, 8] 和 (8, 无穷大)。在每个区间中使用切比雪夫多项式展开。使用的多项式展开与i0
中的相同,但没有乘以主导指数因子。
此函数是 Cephes [1] 例程 i0e
的包装器。对于大的参数 x,i0
很快会溢出。
参考文献
Cephes 数学函数库,www.netlib.org/cephes/
示例
在以下示例中,i0
返回无穷大,而i0e
仍然返回一个有限数。
>>> from scipy.special import i0, i0e
>>> i0(1000.), i0e(1000.)
(inf, 0.012617240455891257)
通过提供 NumPy 数组或列表的 x 在几个点计算函数:
>>> import numpy as np
>>> i0e(np.array([-2., 0., 3.]))
array([0.30850832, 1\. , 0.24300035])
在-10 到 10 之间绘制函数。
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> x = np.linspace(-10., 10., 1000)
>>> y = i0e(x)
>>> ax.plot(x, y)
>>> plt.show()
scipy.special.i1
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.i1.html#scipy.special.i1
scipy.special.i1(x, out=None) = <ufunc 'i1'>
修改的一阶贝塞尔函数。
定义为,
[I_1(x) = \frac{1}{2}x \sum_{k=0}^\infty \frac{(x²/4)^k}{k! (k + 1)!} = -\imath J_1(\imath x),]
其中(J_1)是一阶贝塞尔函数的类型 1。
参数:
xarray_like
参数(浮点数)
outndarray,可选
函数值的可选输出数组
返回:
I标量或 ndarray
在x处的修改贝塞尔函数的值。
参见
iv
修改的一阶贝塞尔函数
i1e
指数缩放的修改的一阶贝塞尔函数
注释
范围被分为两个区间[0, 8]和(8, 无穷大)。在每个区间中使用切比雪夫多项式展开。
此函数是 Cephes 库[1]中i1
例程的封装i1
。
参考文献
[1]
Cephes 数学函数库,www.netlib.org/cephes/
示例
计算一个点处的函数:
>>> from scipy.special import i1
>>> i1(1.)
0.5651591039924851
在多个点计算函数:
>>> import numpy as np
>>> i1(np.array([-2., 0., 6.]))
array([-1.59063685, 0\. , 61.34193678])
绘制函数在-10 到 10 之间的图像。
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> x = np.linspace(-10., 10., 1000)
>>> y = i1(x)
>>> ax.plot(x, y)
>>> plt.show()
scipy.special.i1e
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.i1e.html#scipy.special.i1e
scipy.special.i1e(x, out=None) = <ufunc 'i1e'>
指数级别修正贝塞尔函数的一阶函数。
定义如下:
i1e(x) = exp(-abs(x)) * i1(x)
参数:
x:array_like
参数(浮点数)
out:ndarray,可选
函数值的可选输出数组
返回:
I:标量或者 ndarray
指数级别修正贝塞尔函数的一阶函数在x处的值。
另请参见
iv
第一类修改贝塞尔函数
i1
一阶修改贝塞尔函数
注意
范围分为两个区间:[0, 8]和(8, 无穷大)。在每个区间中使用切比雪夫多项式展开。所使用的多项式展开与i1
中的相同,但不会乘以主导的指数因子。
该函数是 Cephes 库[1]中的i1e
例程的包装器。对于较大的参数x,i1
会快速溢出,因此i1e
非常有用。
参考资料
[1]
Cephes 数学函数库,www.netlib.org/cephes/
示例
在以下示例中,i1
返回无穷大,而i1e
仍然返回有限数值。
>>> from scipy.special import i1, i1e
>>> i1(1000.), i1e(1000.)
(inf, 0.01261093025692863)
通过提供 NumPy 数组或列表来计算函数在多个点的值:
>>> import numpy as np
>>> i1e(np.array([-2., 0., 6.]))
array([-0.21526929, 0\. , 0.15205146])
在-10 到 10 之间绘制函数图像。
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> x = np.linspace(-10., 10., 1000)
>>> y = i1e(x)
>>> ax.plot(x, y)
>>> plt.show()
scipy.special.k0
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.k0.html#scipy.special.k0
scipy.special.k0(x, out=None) = <ufunc 'k0'>
第二类阶数为 0 的修正贝塞尔函数 (K_0)。
此函数有时也被称为零阶第三类修正贝塞尔函数。
参数:
x 数组样式
参数(浮点数)。
out ndarray,可选
可选输出数组用于函数值。
返回值:
K 标量或者 ndarray
在 x 处的修正贝塞尔函数 (K_0) 的值。
另请参阅
kv
修改后的第二类贝塞尔函数的任意阶数。
k0e
指数尺度的第二类修正贝塞尔函数
注释
该范围被分为两个区间 [0, 2] 和 (2, 无穷)。在每个区间内使用切比雪夫多项式展开。
此函数是 Cephes [1] 库中 k0
程序的包装器。
参考文献
[1]
Cephes 数学函数库,www.netlib.org/cephes/
示例
计算一个点上的函数值:
>>> from scipy.special import k0
>>> k0(1.)
0.42102443824070823
计算几个点上的函数值:
>>> import numpy as np
>>> k0(np.array([0.5, 2., 3.]))
array([0.92441907, 0.11389387, 0.0347395 ])
绘制从 0 到 10 的函数图像。
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> x = np.linspace(0., 10., 1000)
>>> y = k0(x)
>>> ax.plot(x, y)
>>> plt.show()
scipy.special.k0e
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.k0e.html#scipy.special.k0e
scipy.special.k0e(x, out=None) = <ufunc 'k0e'>
指数缩放修正贝塞尔函数阶数为 0
定义如下:
k0e(x) = exp(x) * k0(x).
参数:
x类似数组
参数(浮点数)
outndarray,可选
函数值的可选输出数组
返回:
K标量或 ndarray
指数缩放修正贝塞尔函数阶数为 0 在x处的值。
另请参见
kv
任意阶数第二类修正贝塞尔函数
k0
第二类修正贝塞尔函数
注意事项
范围被分为两个区间[0, 2]和(2, 无穷大)。在每个区间中使用切比雪夫多项式展开。
此函数是 Cephes [1]例程k0e
的包装器。对于大参数,k0e
非常有用:对于这些参数,k0
容易下溢。
参考文献
[1]
Cephes 数学函数库,www.netlib.org/cephes/
示例
在以下示例中,k0
返回 0,而k0e
仍然返回一个有用的有限数:
>>> from scipy.special import k0, k0e
>>> k0(1000.), k0e(1000)
(0., 0.03962832160075422)
通过提供一个 NumPy 数组或列表来计算x的函数在多个点上的值:
>>> import numpy as np
>>> k0e(np.array([0.5, 2., 3.]))
array([1.52410939, 0.84156822, 0.6977616 ])
绘制从 0 到 10 的函数图像。
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> x = np.linspace(0., 10., 1000)
>>> y = k0e(x)
>>> ax.plot(x, y)
>>> plt.show()
scipy.special.k1
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.k1.html#scipy.special.k1
scipy.special.k1(x, out=None) = <ufunc 'k1'>
修正贝塞尔函数的第二类,阶数为 1,(K_1(x))。
参数:
x 数组样式
参数(浮点数)
out 数组,可选
可选的输出数组,包含函数值
返回值:
K 标量或者数组
计算修正贝塞尔函数 K 的值,其阶数为 1,x 变量。
另见
kv
任意阶数的修正贝塞尔函数的第二类
k1e
指数尺度的修正贝塞尔函数 K,其阶数为 1
注意事项
范围分为两个区间 [0, 2] 和 (2, 无穷大)。在每个区间内采用切比雪夫多项式展开。
此函数是 Cephes [1] 中的 k1
程序包装器。
参考文献
[1]
Cephes 数学函数库, www.netlib.org/cephes/
示例
计算单个点的函数值:
>>> from scipy.special import k1
>>> k1(1.)
0.6019072301972346
计算多个点的函数值:
>>> import numpy as np
>>> k1(np.array([0.5, 2., 3.]))
array([1.65644112, 0.13986588, 0.04015643])
绘制函数从 0 到 10 的图表。
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> x = np.linspace(0., 10., 1000)
>>> y = k1(x)
>>> ax.plot(x, y)
>>> plt.show()
scipy.special.k1e
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.k1e.html#scipy.special.k1e
scipy.special.k1e(x, out=None) = <ufunc 'k1e'>
指数尺度修正的贝塞尔函数 K 一阶
定义如下:
k1e(x) = exp(x) * k1(x)
参数:
xarray_like
参数(浮点数)
outndarray, 可选参数
可选的输出数组,用于函数值
返回:
K标量或 ndarray
指数尺度修正的贝塞尔函数 K 一阶在 x 处的值。
另见
kv
任意阶数的第二类修正贝塞尔函数
k1
一阶修正贝塞尔函数 K
注意事项
范围被分成两个区间 [0, 2] 和 (2, 无穷大)。每个区间使用切比雪夫多项式展开。
此函数是 Cephes [1] 的 k1e
程序包装。
参考文献
[1]
Cephes 数学函数库,www.netlib.org/cephes/
示例
在下面的例子中,k1
返回 0,而k1e
仍然返回一个有用的浮点数。
>>> from scipy.special import k1, k1e
>>> k1(1000.), k1e(1000.)
(0., 0.03964813081296021)
通过提供一个 NumPy 数组或列表来在多个点计算函数的值:
>>> import numpy as np
>>> k1e(np.array([0.5, 2., 3.]))
array([2.73100971, 1.03347685, 0.80656348])
绘制函数从 0 到 10。
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> x = np.linspace(0., 10., 1000)
>>> y = k1e(x)
>>> ax.plot(x, y)
>>> plt.show()
scipy.special.itj0y0
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.itj0y0.html#scipy.special.itj0y0
scipy.special.itj0y0(x, out=None) = <ufunc 'itj0y0'>
一阶贝塞尔函数积分。
计算积分
[\begin{split}\int_0^x J_0(t) dt \ \int_0^x Y_0(t) dt.\end{split}]
关于 (J_0) 和 (Y_0) 的更多信息请参见j0
和 y0
。
参数:
xarray_like
评估积分的值点。
outndarray 或者 tuple,可选
函数结果的可选输出数组。
返回:
ij0标量或者 ndarray
j0
的积分
iy0标量或者 ndarray
y0
的积分
参考文献
[1]
S. Zhang 和 J.M. Jin,“特殊函数的计算”,Wiley 1996
示例
在一个点评估函数。
>>> from scipy.special import itj0y0
>>> int_j, int_y = itj0y0(1.)
>>> int_j, int_y
(0.9197304100897596, -0.637069376607422)
在几个点评估函数。
>>> import numpy as np
>>> points = np.array([0., 1.5, 3.])
>>> int_j, int_y = itj0y0(points)
>>> int_j, int_y
(array([0\. , 1.24144951, 1.38756725]),
array([ 0\. , -0.51175903, 0.19765826]))
从 0 到 10 绘制函数。
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> x = np.linspace(0., 10., 1000)
>>> int_j, int_y = itj0y0(x)
>>> ax.plot(x, int_j, label="$\int_0^x J_0(t)\,dt$")
>>> ax.plot(x, int_y, label="$\int_0^x Y_0(t)\,dt$")
>>> ax.legend()
>>> plt.show()
scipy.special.it2j0y0
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.it2j0y0.html#scipy.special.it2j0y0
scipy.special.it2j0y0(x, out=None) = <ufunc 'it2j0y0'>
与第一类零阶贝塞尔函数相关的积分。
计算积分
[\begin{split}\int_0^x \frac{1 - J_0(t)}{t} dt \ \int_x^\infty \frac{Y_0(t)}{t} dt.\end{split}]
更多关于 (J_0) 和 (Y_0) 的信息,请参见 j0
和 y0
。
参数:
x:array_like
评估积分的值。
out:ndarrays 元组,可选
可选输出数组用于函数结果。
返回:
ij0:标量或 ndarray
j0
的积分
iy0:标量或 ndarray
y0
的积分
参考资料
[1]
S. Zhang 和 J.M. Jin,“计算特殊函数”,Wiley 1996
示例
在一个点上评估函数。
>>> from scipy.special import it2j0y0
>>> int_j, int_y = it2j0y0(1.)
>>> int_j, int_y
(0.12116524699506871, 0.39527290169929336)
在几个点上评估函数。
>>> import numpy as np
>>> points = np.array([0.5, 1.5, 3.])
>>> int_j, int_y = it2j0y0(points)
>>> int_j, int_y
(array([0.03100699, 0.26227724, 0.85614669]),
array([ 0.26968854, 0.29769696, -0.02987272]))
绘制从 0 到 10 的函数。
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> x = np.linspace(0., 10., 1000)
>>> int_j, int_y = it2j0y0(x)
>>> ax.plot(x, int_j, label=r"$\int_0^x \frac{1-J_0(t)}{t}\,dt$")
>>> ax.plot(x, int_y, label=r"$\int_x^{\infty} \frac{Y_0(t)}{t}\,dt$")
>>> ax.legend()
>>> ax.set_ylim(-2.5, 2.5)
>>> plt.show()
scipy.special.iti0k0
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.iti0k0.html#scipy.special.iti0k0
scipy.special.iti0k0(x, out=None) = <ufunc 'iti0k0'>
修改 Bessel 函数零阶的积分。
计算积分
[\begin{split}\int_0^x I_0(t) dt \ \int_0^x K_0(t) dt.\end{split}]
参数:
xarray_like
评估积分的值。
outndarrays 的元组,可选
用于函数结果的可选输出数组。
返回:
ii0标量或 ndarray
i0
的积分
ik0标量或 ndarray
k0
的积分
参考资料
[1]
S. Zhang 和 J.M. Jin,“特殊函数的计算”,Wiley 1996
示例
在一个点评估函数。
>>> from scipy.special import iti0k0
>>> int_i, int_k = iti0k0(1.)
>>> int_i, int_k
(1.0865210970235892, 1.2425098486237771)
在几个点评估函数。
>>> import numpy as np
>>> points = np.array([0., 1.5, 3.])
>>> int_i, int_k = iti0k0(points)
>>> int_i, int_k
(array([0\. , 1.80606937, 6.16096149]),
array([0\. , 1.39458246, 1.53994809]))
从 0 到 5 绘制函数。
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> x = np.linspace(0., 5., 1000)
>>> int_i, int_k = iti0k0(x)
>>> ax.plot(x, int_i, label="$\int_0^x I_0(t)\,dt$")
>>> ax.plot(x, int_k, label="$\int_0^x K_0(t)\,dt$")
>>> ax.legend()
>>> plt.show()
scipy.special.it2i0k0
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.it2i0k0.html#scipy.special.it2i0k0
scipy.special.it2i0k0(x, out=None) = <ufunc 'it2i0k0'>
与修改的贝塞尔函数的积分有关。
计算积分
[\begin{split}\int_0^x \frac{I_0(t) - 1}{t} dt \ \int_x^\infty \frac{K_0(t)}{t} dt.\end{split}]
参数:
x类似数组
评估积分的值。
outndarrays 的元组,可选的
函数结果的可选输出数组。
返回:
ii0标量或 ndarray
对于i0
的积分
ik0标量或 ndarray
对于k0
的积分
参考文献
[1]
S. Zhang 和 J.M. Jin,《特殊函数的计算》,Wiley 1996
示例
在一个点评估函数。
>>> from scipy.special import it2i0k0
>>> int_i, int_k = it2i0k0(1.)
>>> int_i, int_k
(0.12897944249456852, 0.2085182909001295)
在几个点评估函数。
>>> import numpy as np
>>> points = np.array([0.5, 1.5, 3.])
>>> int_i, int_k = it2i0k0(points)
>>> int_i, int_k
(array([0.03149527, 0.30187149, 1.50012461]),
array([0.66575102, 0.0823715 , 0.00823631]))
绘制从 0 到 5 的函数。
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> x = np.linspace(0., 5., 1000)
>>> int_i, int_k = it2i0k0(x)
>>> ax.plot(x, int_i, label=r"$\int_0^x \frac{I_0(t)-1}{t}\,dt$")
>>> ax.plot(x, int_k, label=r"$\int_x^{\infty} \frac{K_0(t)}{t}\,dt$")
>>> ax.legend()
>>> ax.set_ylim(0, 10)
>>> plt.show()
scipy.special.besselpoly
scipy.special.besselpoly(a, lmb, nu, out=None) = <ufunc 'besselpoly'>
第一类贝塞尔函数的加权积分。
计算
[\int_0¹ x^\lambda J_\nu(2 a x) , dx]
这里的(J_\nu)是贝塞尔函数,(\lambda=lmb), (\nu=nu)。
参数:
a类似数组
贝塞尔函数内的比例因子。
lmb类似数组
x的幂
nu类似数组
贝塞尔函数的阶数。
outndarray,可选
函数结果的可选输出数组。
返回:
标量或者 ndarray
积分的值。
参考资料
[1]
Cephes 数学函数库,www.netlib.org/cephes/
示例
为一个参数集评估函数。
>>> from scipy.special import besselpoly
>>> besselpoly(1, 1, 1)
0.24449718372863877
评估不同比例因子下的函数。
>>> import numpy as np
>>> factors = np.array([0., 3., 6.])
>>> besselpoly(factors, 1, 1)
array([ 0\. , -0.00549029, 0.00140174])
绘制不同幂次、阶数和比例尺度的函数图像。
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> powers = np.linspace(0, 10, 100)
>>> orders = [1, 2, 3]
>>> scales = [1, 2]
>>> all_combinations = [(order, scale) for order in orders
... for scale in scales]
>>> for order, scale in all_combinations:
... ax.plot(powers, besselpoly(scale, powers, order),
... label=rf"$\nu={order}, a={scale}$")
>>> ax.legend()
>>> ax.set_xlabel(r"$\lambda$")
>>> ax.set_ylabel(r"$\int_0¹ x^{\lambda} J_{\nu}(2ax)\,dx$")
>>> plt.show()
scipy.special.jvp
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.jvp.html#scipy.special.jvp
scipy.special.jvp(v, z, n=1)
计算一阶类贝塞尔函数的导数。
计算贝塞尔函数 Jv 关于 z 的第 n 阶导数。
参数:
v数组或浮点数
贝塞尔函数的阶数
z复数
要评估导数的参数;可以是实数或复数。
nint,默认为 1
导数的阶数。对于 0 返回贝塞尔函数jv
本身。
返回:
标量或 ndarray
贝塞尔函数导数的值。
注释
使用关系 DLFM 10.6.7 计算导数 [2]。
参考文献
[1]
Zhang, Shanjie 和 Jin, Jianming. “Special Functions 的计算”, John Wiley and Sons, 1996, 第五章。people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
[2]
NIST 数学函数数字图书馆。dlmf.nist.gov/10.6.E7
示例
计算阶数为 0 时一阶类贝塞尔函数及其前两阶导数在 1 处的值。
>>> from scipy.special import jvp
>>> jvp(0, 1, 0), jvp(0, 1, 1), jvp(0, 1, 2)
(0.7651976865579666, -0.44005058574493355, -0.3251471008130331)
提供一个数组作为 v 来计算一阶类贝塞尔函数在 1 处的多个阶数的第一阶导数。
>>> jvp([0, 1, 2], 1, 1)
array([-0.44005059, 0.3251471 , 0.21024362])
提供一个数组作为 z 来计算一阶类贝塞尔函数阶数为 0 时在多个点处的第一阶导数。
>>> import numpy as np
>>> points = np.array([0., 1.5, 3.])
>>> jvp(0, points, 1)
array([-0\. , -0.55793651, -0.33905896])
绘制一阶类贝塞尔函数及其前三阶导数。
>>> import matplotlib.pyplot as plt
>>> x = np.linspace(-10, 10, 1000)
>>> fig, ax = plt.subplots()
>>> ax.plot(x, jvp(1, x, 0), label=r"$J_1$")
>>> ax.plot(x, jvp(1, x, 1), label=r"$J_1'$")
>>> ax.plot(x, jvp(1, x, 2), label=r"$J_1''$")
>>> ax.plot(x, jvp(1, x, 3), label=r"$J_1'''$")
>>> plt.legend()
>>> plt.show()
scipy.special.yvp
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.yvp.html#scipy.special.yvp
scipy.special.yvp(v, z, n=1)
计算第二类贝塞尔函数的导数。
计算贝塞尔函数 Yv 对 z 的第 n 阶导数。
参数:
varray_like of float
贝塞尔函数的阶数
zcomplex
评估导数的参数
nint,默认为 1
求导阶数。对于 0 返回 BEssel 函数 yv
返回值:
scalar 或 ndarray
第 n 阶贝塞尔函数的导数。
参见
yv
第二类贝塞尔函数
注释
该导数是使用关系 DLFM 10.6.7 计算的 [2]。
参考文献
[1]
Zhang, Shanjie 和 Jin, Jianming。“特殊函数的计算”,John Wiley and Sons,1996 年,第五章。people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
[2]
NIST 数字图书馆的数学函数。dlmf.nist.gov/10.6.E7
示例
计算阶数为 0 的第二类贝塞尔函数及其在 1 处的前两个导数。
>>> from scipy.special import yvp
>>> yvp(0, 1, 0), yvp(0, 1, 1), yvp(0, 1, 2)
(0.088256964215677, 0.7812128213002889, -0.8694697855159659)
通过为 v 提供数组,在 1 处计算阶数为 0 的第二类贝塞尔函数的一阶导数。
>>> yvp([0, 1, 2], 1, 1)
array([0.78121282, 0.86946979, 2.52015239])
通过为 z 提供数组,计算阶数为 0 的第二类贝塞尔函数的一阶导数在几个点处。
>>> import numpy as np
>>> points = np.array([0.5, 1.5, 3.])
>>> yvp(0, points, 1)
array([ 1.47147239, 0.41230863, -0.32467442])
绘制阶数为 1 的第二类贝塞尔函数及其前三个导数。
>>> import matplotlib.pyplot as plt
>>> x = np.linspace(0, 5, 1000)
>>> x[0] += 1e-15
>>> fig, ax = plt.subplots()
>>> ax.plot(x, yvp(1, x, 0), label=r"$Y_1$")
>>> ax.plot(x, yvp(1, x, 1), label=r"$Y_1'$")
>>> ax.plot(x, yvp(1, x, 2), label=r"$Y_1''$")
>>> ax.plot(x, yvp(1, x, 3), label=r"$Y_1'''$")
>>> ax.set_ylim(-10, 10)
>>> plt.legend()
>>> plt.show()
scipy.special.kvp
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.kvp.html#scipy.special.kvp
scipy.special.kvp(v, z, n=1)
计算实数阶修正贝塞尔函数 Kv(z)的导数
Kv(z)是第二类修正贝塞尔函数。导数是相对于z计算的。
参数:
v浮点数数组
贝塞尔函数的阶数
z复数数组
计算导数的论点
n整数,默认为 1
导数的阶数。对于 0,返回贝塞尔函数kv
本身。
返回值:
outndarray
结果
另见
注释
使用关系 DLFM 10.29.5 计算导数[2]。
参考文献
[1]
张善杰和金建明。“特殊函数的计算”,约翰威利和儿子,1996 年,第六章。people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
[2]
NIST 数学函数数字库。dlmf.nist.gov/10.29.E5
示例
在 1 处计算第二类修正贝塞尔函数及其前两个导数的阶数。
>>> from scipy.special import kvp
>>> kvp(0, 1, 0), kvp(0, 1, 1), kvp(0, 1, 2)
(0.42102443824070834, -0.6019072301972346, 1.0229316684379428)
通过为v提供一个数组,在 1 处计算几个阶数的第二类修正贝塞尔函数的一阶导数。
>>> kvp([0, 1, 2], 1, 1)
array([-0.60190723, -1.02293167, -3.85158503])
通过为z提供一个数组,计算几个点的第二类修正贝塞尔函数的一阶导数,其中z是浮点数的数组。
>>> import numpy as np
>>> points = np.array([0.5, 1.5, 3.])
>>> kvp(0, points, 1)
array([-1.65644112, -0.2773878 , -0.04015643])
绘制第二类修正贝塞尔函数及其前三个导数。
>>> import matplotlib.pyplot as plt
>>> x = np.linspace(0, 5, 1000)
>>> fig, ax = plt.subplots()
>>> ax.plot(x, kvp(1, x, 0), label=r"$K_1$")
>>> ax.plot(x, kvp(1, x, 1), label=r"$K_1'$")
>>> ax.plot(x, kvp(1, x, 2), label=r"$K_1''$")
>>> ax.plot(x, kvp(1, x, 3), label=r"$K_1'''$")
>>> ax.set_ylim(-2.5, 2.5)
>>> plt.legend()
>>> plt.show()
scipy.special.ivp
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.ivp.html#scipy.special.ivp
scipy.special.ivp(v, z, n=1)
计算一类修正贝塞尔函数的导数。
计算一类修正贝塞尔函数Iv关于z的第 n 阶导数。
参数:
varray_like 或 float
贝塞尔函数的阶数
zarray_like
用于计算导数的参数;可以是实数或复数。
nint,默认值 1
导数的阶数。对于 0,返回贝塞尔函数iv
本身。
返回:
标量或 ndarray
修正贝塞尔函数的第 n 阶导数。
另请参阅
iv
注释
使用关系 DLFM 10.29.5 计算导数[2]。
参考文献
[1]
张善杰和金建明。“特殊函数的计算”,John Wiley and Sons,1996 年,第六章。people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
[2]
NIST 数学函数数字图书馆。dlmf.nist.gov/10.29.E5
示例
计算一类修正贝塞尔函数的一阶导数为 0 阶和其在 1 处的前两个导数。
>>> from scipy.special import ivp
>>> ivp(0, 1, 0), ivp(0, 1, 1), ivp(0, 1, 2)
(1.2660658777520084, 0.565159103992485, 0.7009067737595233)
通过为v提供数组,计算一类修正贝塞尔函数的一阶导数的多个阶在 1 处的值。
>>> ivp([0, 1, 2], 1, 1)
array([0.5651591 , 0.70090677, 0.29366376])
通过为z提供数组,计算一类修正贝塞尔函数的一阶导数为 0 阶在几个点处的值。
>>> import numpy as np
>>> points = np.array([0., 1.5, 3.])
>>> ivp(0, points, 1)
array([0\. , 0.98166643, 3.95337022])
绘制一类修正贝塞尔函数的一阶导数为 1 阶及其前三阶导数。
>>> import matplotlib.pyplot as plt
>>> x = np.linspace(-5, 5, 1000)
>>> fig, ax = plt.subplots()
>>> ax.plot(x, ivp(1, x, 0), label=r"$I_1$")
>>> ax.plot(x, ivp(1, x, 1), label=r"$I_1'$")
>>> ax.plot(x, ivp(1, x, 2), label=r"$I_1''$")
>>> ax.plot(x, ivp(1, x, 3), label=r"$I_1'''$")
>>> plt.legend()
>>> plt.show()
scipy.special.h1vp
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.h1vp.html#scipy.special.h1vp
scipy.special.h1vp(v, z, n=1)
计算对z的汉克尔函数 H1v(z)的导数。
参数:
varray_like
汉克尔函数的阶数
zarray_like
评估导数的参数。可以是实数或复数。
nint,默认为 1
导数的阶数。对于 0 返回汉克尔函数h1v本身。
返回:
标量或 ndarray
汉克尔函数导数的值。
另见
hankel1
注意
使用关系 DLFM 10.6.7 [2] 计算导数。
参考资料
[1]
张, 善杰 和 金, 建明。“特殊函数的计算”,约翰·威利和儿子出版社, 1996 年, 第五章。people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
[2]
NIST 数字数学函数库。dlmf.nist.gov/10.6.E7
示例
计算阶数为 0 的第一类汉克尔函数及其在 1 处的前两个导数。
>>> from scipy.special import h1vp
>>> h1vp(0, 1, 0), h1vp(0, 1, 1), h1vp(0, 1, 2)
((0.7651976865579664+0.088256964215677j),
(-0.44005058574493355+0.7812128213002889j),
(-0.3251471008130329-0.8694697855159659j))
通过提供一个数组v,计算在 1 处多个阶数的第一类汉克尔函数的第一导数。
>>> h1vp([0, 1, 2], 1, 1)
array([-0.44005059+0.78121282j, 0.3251471 +0.86946979j,
0.21024362+2.52015239j])
通过提供一个数组z,计算在多个点处阶数为 0 的第一类汉克尔函数的第一导数。
>>> import numpy as np
>>> points = np.array([0.5, 1.5, 3.])
>>> h1vp(0, points, 1)
array([-0.24226846+1.47147239j, -0.55793651+0.41230863j,
-0.33905896-0.32467442j])
scipy.special.h2vp
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.h2vp.html#scipy.special.h2vp
scipy.special.h2vp(v, z, n=1)
计算 Hankel 函数 H2v(z)关于z的导数。
参数:
varray_like
Hankel 函数的阶数
zarray_like
求导数的自变量。可以是实数或复数。
nint,默认为 1
导数的阶数。对于 0 返回 Hankel 函数h2v本身。
返回:
标量或者 ndarray
Hankel 函数导数的值。
另请参阅
hankel2
注意事项
导数的计算使用 DLFM 10.6.7 关系 [2]。
参考文献
[1]
张善杰和金建明。“特殊函数的计算”,John Wiley and Sons 出版,1996 年,第五章。people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
[2]
NIST 数学函数数字图书馆。dlmf.nist.gov/10.6.E7
示例
计算阶数为 0 的第二类 Hankel 函数在 1 处及其前两个导数。
>>> from scipy.special import h2vp
>>> h2vp(0, 1, 0), h2vp(0, 1, 1), h2vp(0, 1, 2)
((0.7651976865579664-0.088256964215677j),
(-0.44005058574493355-0.7812128213002889j),
(-0.3251471008130329+0.8694697855159659j))
提供v数组,计算一阶导数的第二类 Hankel 函数在 1 处的多个阶数。
>>> h2vp([0, 1, 2], 1, 1)
array([-0.44005059-0.78121282j, 0.3251471 -0.86946979j,
0.21024362-2.52015239j])
提供z数组,计算阶数为 0 的第二类 Hankel 函数在多个点处的一阶导数。
>>> import numpy as np
>>> points = np.array([0.5, 1.5, 3.])
>>> h2vp(0, points, 1)
array([-0.24226846-1.47147239j, -0.55793651-0.41230863j,
-0.33905896+0.32467442j])
scipy.special.spherical_jn
scipy.special.spherical_jn(n, z, derivative=False)
第一类球贝塞尔函数或其导数。
定义为[1],
[j_n(z) = \sqrt{\frac{\pi}{2z}} J_{n + 1/2}(z),]
其中(J_n)是第一类贝塞尔函数。
参数:
nint,类数组
Bessel 函数的顺序(n >= 0)。
z复数或浮点数,类数组
贝塞尔函数的参数。
derivativebool,可选
如果为 True,则返回导数值(而不是函数本身)。
返回:
jnndarray
注意事项
对于大于顺序的实数参数,使用升序递推计算函数[2]。对于小的实数或复数参数,使用与第一类圆柱贝塞尔函数的定义关系。
使用关系计算导数[3],
[ \begin{align}\begin{aligned}j_n'(z) = j_{n-1}(z) - \frac{n + 1}{z} j_n(z).\j_0'(z) = -j_1(z)\end{aligned}\end{align} ]
自 0.18.0 版本起新增。
参考文献
[1]
[2]
[3]
[AS]
米尔顿·阿布拉莫维茨和艾琳·A·斯特甘(Milton Abramowitz and Irene A. Stegun)主编。数学函数手册,包含公式、图表和数学表格。纽约:多佛出版社,1972 年。
示例
第一类球贝塞尔函数(j_n)接受实数和复数第二参数。它们可以返回复数类型:
>>> from scipy.special import spherical_jn
>>> spherical_jn(0, 3+5j)
(-9.878987731663194-8.021894345786002j)
>>> type(spherical_jn(0, 3+5j))
<class 'numpy.complex128'>
我们可以验证在区间([1, 2])中的(n=3)的导数关系:
>>> import numpy as np
>>> x = np.arange(1.0, 2.0, 0.01)
>>> np.allclose(spherical_jn(3, x, True),
... spherical_jn(2, x) - 4/x * spherical_jn(3, x))
True
几个具有实数参数的(j_n):
>>> import matplotlib.pyplot as plt
>>> x = np.arange(0.0, 10.0, 0.01)
>>> fig, ax = plt.subplots()
>>> ax.set_ylim(-0.5, 1.5)
>>> ax.set_title(r'Spherical Bessel functions $j_n$')
>>> for n in np.arange(0, 4):
... ax.plot(x, spherical_jn(n, x), label=rf'$j_{n}$')
>>> plt.legend(loc='best')
>>> plt.show()
scipy.special.spherical_yn
scipy.special.spherical_yn(n, z, derivative=False)
第二类球贝塞尔函数或其导数。
定义如[1],
[y_n(z) = \sqrt{\frac{\pi}{2z}} Y_{n + 1/2}(z),]
其中(Y_n)是第二类贝塞尔函数。
参数:
n整数,类数组
贝塞尔函数的阶数(n >= 0)。
z复数或浮点数,类数组
贝塞尔函数的自变量。
derivative布尔值,可选项
如果为 True,则返回导数值(而不是函数本身)。
返回:
ynndarray
注释
对于实数自变量,使用递增的递推计算函数[2]。对于复数自变量,使用与第二类圆柱贝塞尔函数的定义关系。
使用关系计算导数[3]。
[ \begin{align}\begin{aligned}y_n' = y_{n-1} - \frac{n + 1}{z} y_n.\y_0' = -y_1\end{aligned}\end{align} ]
新功能版本 0.18.0。
参考文献
[1]
[2]
[3]
[AS]
米尔顿·阿布拉莫维奇和艾琳·A·斯特根(Milton Abramowitz and Irene A. Stegun)编辑。数学函数手册:带有公式、图表和数学表格。纽约:多佛尔出版社,1972 年。
例子
第二类球贝塞尔函数(y_n)接受实数和复数作为第二个自变量。它们可以返回复数类型:
>>> from scipy.special import spherical_yn
>>> spherical_yn(0, 3+5j)
(8.022343088587197-9.880052589376795j)
>>> type(spherical_yn(0, 3+5j))
<class 'numpy.complex128'>
我们可以验证关于导数的关系,从(n=3)的注释中,在区间([1, 2])内:
>>> import numpy as np
>>> x = np.arange(1.0, 2.0, 0.01)
>>> np.allclose(spherical_yn(3, x, True),
... spherical_yn(2, x) - 4/x * spherical_yn(3, x))
True
带有实数自变量的前几个(y_n):
>>> import matplotlib.pyplot as plt
>>> x = np.arange(0.0, 10.0, 0.01)
>>> fig, ax = plt.subplots()
>>> ax.set_ylim(-2.0, 1.0)
>>> ax.set_title(r'Spherical Bessel functions $y_n$')
>>> for n in np.arange(0, 4):
... ax.plot(x, spherical_yn(n, x), label=rf'$y_{n}$')
>>> plt.legend(loc='best')
>>> plt.show()
scipy.special.spherical_in
scipy.special.spherical_in(n, z, derivative=False)
修改后的第一类球面贝塞尔函数或其导数。
定义如下 [1],
[i_n(z) = \sqrt{\frac{\pi}{2z}} I_{n + 1/2}(z),]
其中 (I_n) 是修改后的第一类圆柱贝塞尔函数。
参数:
nint, array_like
贝塞尔函数的阶数 (n >= 0)。
z复数或浮点数,array_like
贝塞尔函数的自变量。
derivative布尔值,可选
如果为 True,则返回导数值(而非函数本身)。
返回:
inndarray
注意事项
使用其与修改后的第一类圆柱贝塞尔函数的定义关系来计算函数。
使用关系计算导数 [2],
[ \begin{align}\begin{aligned}i_n' = i_{n-1} - \frac{n + 1}{z} i_n.\i_1' = i_0\end{aligned}\end{align} ]
自 0.18.0 版本起新增。
参考文献
[1]
[2]
[AS]
Milton Abramowitz 和 Irene A. Stegun 编辑。Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. 纽约:Dover,1972 年。
示例
修改后的第一类球面贝塞尔函数 (i_n) 接受实数和复数第二个参数。它们可以返回复数类型:
>>> from scipy.special import spherical_in
>>> spherical_in(0, 3+5j)
(-1.1689867793369182-1.2697305267234222j)
>>> type(spherical_in(0, 3+5j))
<class 'numpy.complex128'>
我们可以验证在区间 ([1, 2]) 内 (n=3) 时,从注释中得到的导数关系:
>>> import numpy as np
>>> x = np.arange(1.0, 2.0, 0.01)
>>> np.allclose(spherical_in(3, x, True),
... spherical_in(2, x) - 4/x * spherical_in(3, x))
True
前几个具有实数参数的 (i_n):
>>> import matplotlib.pyplot as plt
>>> x = np.arange(0.0, 6.0, 0.01)
>>> fig, ax = plt.subplots()
>>> ax.set_ylim(-0.5, 5.0)
>>> ax.set_title(r'Modified spherical Bessel functions $i_n$')
>>> for n in np.arange(0, 4):
... ax.plot(x, spherical_in(n, x), label=rf'$i_{n}$')
>>> plt.legend(loc='best')
>>> plt.show()
scipy.special.spherical_kn
scipy.special.spherical_kn(n, z, derivative=False)
修改的球形贝塞尔函数第二类或其导数。
定义如[1],
[k_n(z) = \sqrt{\frac{\pi}{2z}} K_{n + 1/2}(z),]
其中 (K_n) 是修改的第二类贝塞尔函数。
参数:
n 整数,数组类型
Bessel 函数的顺序((n \geq 0))。
z 复数或浮点数,数组类型
Bessel 函数的参数。
derivative 布尔值,可选
如果为 True,则返回导数值(而不是函数本身)。
返回:
kn ndarray
注释
使用其与修改的圆柱形贝塞尔函数第二类的定义关系计算函数。
利用关系计算导数[2],
[ \begin{align}\begin{aligned}k_n' = -k_{n-1} - \frac{n + 1}{z} k_n.\k_0' = -k_1\end{aligned}\end{align} ]
0.18.0 版本中的新功能。
参考资料
[1]
[2]
[AS]
Milton Abramowitz 和 Irene A. Stegun,编。 Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables。 New York: Dover, 1972.
示例
修改的球形贝塞尔函数第二类 (k_n) 接受实数和复数第二参数。它们可以返回复数类型:
>>> from scipy.special import spherical_kn
>>> spherical_kn(0, 3+5j)
(0.012985785614001561+0.003354691603137546j)
>>> type(spherical_kn(0, 3+5j))
<class 'numpy.complex128'>
我们可以验证关于导数的关系来自于注释,(n=3)在区间([1, 2]):
>>> import numpy as np
>>> x = np.arange(1.0, 2.0, 0.01)
>>> np.allclose(spherical_kn(3, x, True),
... - 4/x * spherical_kn(3, x) - spherical_kn(2, x))
True
带有实数参数的前几个 (k_n):
>>> import matplotlib.pyplot as plt
>>> x = np.arange(0.0, 4.0, 0.01)
>>> fig, ax = plt.subplots()
>>> ax.set_ylim(0.0, 5.0)
>>> ax.set_title(r'Modified spherical Bessel functions $k_n$')
>>> for n in np.arange(0, 4):
... ax.plot(x, spherical_kn(n, x), label=rf'$k_{n}$')
>>> plt.legend(loc='best')
>>> plt.show()
scipy.special.riccati_jn
scipy.special.riccati_jn(n, x)
计算第一类里卡提-贝塞尔函数及其导数。
第一类里卡提-贝塞尔函数定义为 (x j_n(x)),其中 (j_n) 是第一类阶数为 (n) 的球贝塞尔函数。
此函数计算所有订单包括 n 的里卡提-贝塞尔函数的值和第一阶导数。
参数:
nint
函数计算的最大阶数
xfloat
在其处评估的参数
返回值:
jnndarray
j0(x) 到 jn(x) 的值
jnpndarray
第一阶导数 j0’(x), …, jn’(x)
注意事项
计算是通过向后递归进行的,使用关系 DLMF 10.51.1 [2].
由张善杰和金建明创建的 Fortran 程序包装器 [1].
参考文献
[1]
Zhang, Shanjie 和 Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
[2]
NIST 数字数学函数库。dlmf.nist.gov/10.51.E1
scipy.special.riccati_yn
scipy.special.riccati_yn(n, x)
计算第二类里卡提-贝塞尔函数及其导数。
第二类里卡提-贝塞尔函数定义为 (x y_n(x)),其中 (y_n) 是第二类球贝塞尔函数的阶数为 (n)。
此函数计算所有顺序直到包括 n 的函数值和第一阶导数。
参数:
nint
函数计算的最大阶数
xfloat
要评估的参数
返回:
ynndarray
y0(x), …, yn(x) 的值
ynpndarray
第一阶导数 y0’(x), …, yn’(x)
注意
计算通过升序递归进行,使用关系 DLMF 10.51.1 [2]。
张善杰和金建明创建的 Fortran 程序包装器 [1]。
参考文献
[1]
张善杰和金建明。“特殊函数的计算”,约翰·威利和儿子,1996 年。people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
[2]
美国国家标准技术研究所数学函数数字图书馆。dlmf.nist.gov/10.51.E1
scipy.special.struve
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.struve.html#scipy.special.struve
scipy.special.struve(v, x, out=None) = <ufunc 'struve'>
Struve 函数。
返回阶数v在x处的 Struve 函数值。Struve 函数定义如下,
[H_v(x) = (z/2)^{v + 1} \sum_{n=0}^\infty \frac{(-1)^n (z/2)^{2n}}{\Gamma(n + \frac{3}{2}) \Gamma(n + v + \frac{3}{2})},]
其中(\Gamma)是 Gamma 函数。
参数:
v 数组类型
Struve 函数的阶数(浮点数)。
x数组类型
Struve 函数的参数(浮点数;必须为正,除非v是整数)。
out ndarray,可选
函数结果的可选输出数组
返回:
H 标量或者 ndarray
阶数v在x处的 Struve 函数值。
另见
modstruve
修改的 Struve 函数
注意
讨论在[1]中使用的三种方法来评估 Struve 函数:
-
幂级数
-
Bessel 函数的展开(如果( |z| < |v| + 20 ))。
-
渐近大-z 展开(如果(z \geq 0.7v + 12))。
基于和式中最大项估计的舍入误差,并返回与最小误差相关联的结果。
参考资料
[1]
NIST 数字数学函数库 dlmf.nist.gov/11
示例
计算阶数为 1 的 Struve 函数在 2 处的值。
>>> import numpy as np
>>> from scipy.special import struve
>>> import matplotlib.pyplot as plt
>>> struve(1, 2.)
0.6467637282835622
通过为阶参数v提供列表,计算 2 阶的 Struve 函数,阶数为 1、2 和 3。
>>> struve([1, 2, 3], 2.)
array([0.64676373, 0.28031806, 0.08363767])
通过为x提供数组,计算多个点处阶数为 1 的 Struve 函数。
>>> points = np.array([2., 5., 8.])
>>> struve(1, points)
array([0.64676373, 0.80781195, 0.48811605])
通过为v和z提供广播到正确形状的数组,计算多个点处多个阶数的 Struve 函数。
>>> orders = np.array([[1], [2], [3]])
>>> points.shape, orders.shape
((3,), (3, 1))
>>> struve(orders, points)
array([[0.64676373, 0.80781195, 0.48811605],
[0.28031806, 1.56937455, 1.51769363],
[0.08363767, 1.50872065, 2.98697513]])
绘制从-10 到 10 的 0 到 3 阶 Struve 函数。
>>> fig, ax = plt.subplots()
>>> x = np.linspace(-10., 10., 1000)
>>> for i in range(4):
... ax.plot(x, struve(i, x), label=f'$H_{i!r}$')
>>> ax.legend(ncol=2)
>>> ax.set_xlim(-10, 10)
>>> ax.set_title(r"Struve functions $H_{\nu}$")
>>> plt.show()
scipy.special.modstruve
scipy.special.modstruve(v, x, out=None) = <ufunc 'modstruve'>
修改 Struve 函数。
返回顺序 v 处 x 处修改 Struve 函数的值。修改 Struve 函数定义为,
[L_v(x) = -\imath \exp(-\pi\imath v/2) H_v(\imath x),]
其中 (H_v) 是 Struve 函数。
参数:
v array_like
修改 Struve 函数的顺序(float)。
x array_like
Struve 函数的参数(float;必须为正,除非 v 是整数)。
out ndarray,可选
函数结果的可选输出数组
返回:
L scalar 或 ndarray
顺序 v 处 x 处修改 Struve 函数的值。
参见
struve
注意事项
在 [1] 中讨论了三种方法来评估函数:
-
幂级数
-
在 Bessel 函数的展开(如果 (|x| < |v| + 20))
-
渐近大 x 展开(如果 (x \geq 0.7v + 12))
根据总和中的最大项估计舍入误差,并返回与最小误差相关的结果。
参考资料
[1]
NIST 数字数学函数库 dlmf.nist.gov/11
示例
计算顺序为 1 的修改 Struve 函数在 2 处的值。
>>> import numpy as np
>>> from scipy.special import modstruve
>>> import matplotlib.pyplot as plt
>>> modstruve(1, 2.)
1.102759787367716
通过提供顺序参数 v 的列表,在 2 处计算顺序为 1、2 和 3 的修改 Struve 函数。
>>> modstruve([1, 2, 3], 2.)
array([1.10275979, 0.41026079, 0.11247294])
通过提供一个 x 的数组,计算几个点的一阶修改 Struve 函数。
>>> points = np.array([2., 5., 8.])
>>> modstruve(1, points)
array([ 1.10275979, 23.72821578, 399.24709139])
通过提供 v 和 z 的数组,在几个点上计算几个顺序的修改 Struve 函数。这些数组必须能够广播到正确的形状。
>>> orders = np.array([[1], [2], [3]])
>>> points.shape, orders.shape
((3,), (3, 1))
>>> modstruve(orders, points)
array([[1.10275979e+00, 2.37282158e+01, 3.99247091e+02],
[4.10260789e-01, 1.65535979e+01, 3.25973609e+02],
[1.12472937e-01, 9.42430454e+00, 2.33544042e+02]])
绘制从 -5 到 5 的顺序为 0 到 3 的修改 Struve 函数。
>>> fig, ax = plt.subplots()
>>> x = np.linspace(-5., 5., 1000)
>>> for i in range(4):
... ax.plot(x, modstruve(i, x), label=f'$L_{i!r}$')
>>> ax.legend(ncol=2)
>>> ax.set_xlim(-5, 5)
>>> ax.set_title(r"Modified Struve functions $L_{\nu}$")
>>> plt.show()
scipy.special.itstruve0
scipy.special.itstruve0(x, out=None) = <ufunc 'itstruve0'>
零阶斯特鲁夫函数的积分。
[I = \int_0^x H_0(t),dt]
参数:
xarray_like
积分上限(浮点数)。
outndarray,可选
函数值的可选输出数组
返回:
I标量或 ndarray
从 0 到x的[H_0]的积分。
另请参见
由此函数积分的函数。
注:
由张善杰和金建明创建的 Fortran 例程的包装器[1]。
参考文献
[1]
Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
示例
在一个点上评估函数。
>>> import numpy as np
>>> from scipy.special import itstruve0
>>> itstruve0(1.)
0.30109042670805547
通过为x提供一个数组,在多个点上评估函数。
>>> points = np.array([1., 2., 3.5])
>>> itstruve0(points)
array([0.30109043, 1.01870116, 1.96804581])
绘制从-20 到 20 的函数。
>>> import matplotlib.pyplot as plt
>>> x = np.linspace(-20., 20., 1000)
>>> istruve0_values = itstruve0(x)
>>> fig, ax = plt.subplots()
>>> ax.plot(x, istruve0_values)
>>> ax.set_xlabel(r'$x$')
>>> ax.set_ylabel(r'$\int_0^{x}H_0(t)\,dt$')
>>> plt.show()
scipy.special.it2struve0
scipy.special.it2struve0(x, out=None) = <ufunc 'it2struve0'>
与 0 阶斯特鲁夫函数相关的积分。
返回积分,
[\int_x^\infty \frac{H_0(t)}{t},dt]
其中(H_0)是 0 阶斯特鲁夫函数。
参数:
xarray_like
积分的下限。
out ndarray,可选
函数值的可选输出数组
返回:
I标量或 ndarray
积分的值。
另请参阅
struve
注意
由张善杰和金建明创建的 Fortran 例程的包装器 [1]。
参考文献
[1]
张善杰和金建明,《特殊函数的计算》,John Wiley and Sons 出版,1996 年。people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
示例
在一个点上评估函数。
>>> import numpy as np
>>> from scipy.special import it2struve0
>>> it2struve0(1.)
0.9571973506383524
通过为x提供数组,在多个点上评估函数。
>>> points = np.array([1., 2., 3.5])
>>> it2struve0(points)
array([0.95719735, 0.46909296, 0.10366042])
绘制从-10 到 10 的函数。
>>> import matplotlib.pyplot as plt
>>> x = np.linspace(-10., 10., 1000)
>>> it2struve0_values = it2struve0(x)
>>> fig, ax = plt.subplots()
>>> ax.plot(x, it2struve0_values)
>>> ax.set_xlabel(r'$x$')
>>> ax.set_ylabel(r'$\int_x^{\infty}\frac{H_0(t)}{t}\,dt$')
>>> plt.show()
scipy.special.itmodstruve0
scipy.special.itmodstruve0(x, out=None) = <ufunc 'itmodstruve0'>
阶数为 0 的修改 Struve 函数的积分。
[I = \int_0^x L_0(t),dt]
参数:
xarray_like
积分的上限(浮点数)。
outndarray, 可选
函数值的可选输出数组
返回:
I标量或 ndarray
从 0 到 x 的[L_0]的积分。
参见
modstruve
通过此函数进行积分的修改 Struve 函数
注意事项
由张善杰和金建明创建的 Fortran 例程的包装器[1]。
参考文献
[1]
Zhang, Shanjie 和 Jin, Jianming. “Special Functions 的计算”, John Wiley and Sons, 1996. people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
示例
在一个点上评估函数。
>>> import numpy as np
>>> from scipy.special import itmodstruve0
>>> itmodstruve0(1.)
0.3364726286440384
通过为x提供数组,在几个点上评估函数。
>>> points = np.array([1., 2., 3.5])
>>> itmodstruve0(points)
array([0.33647263, 1.588285 , 7.60382578])
绘制从 -10 到 10 的函数。
>>> import matplotlib.pyplot as plt
>>> x = np.linspace(-10., 10., 1000)
>>> itmodstruve0_values = itmodstruve0(x)
>>> fig, ax = plt.subplots()
>>> ax.plot(x, itmodstruve0_values)
>>> ax.set_xlabel(r'$x$')
>>> ax.set_ylabel(r'$\int_0^xL_0(t)\,dt$')
>>> plt.show()
scipy.special.bdtr
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.bdtr.html#scipy.special.bdtr
scipy.special.bdtr(k, n, p, out=None) = <ufunc 'bdtr'>
二项分布累积分布函数。
二项概率密度的前 floor(k) 项的和。
[\mathrm{bdtr}(k, n, p) = \sum_{j=0}^{\lfloor k \rfloor} {{n}\choose{j}} p^j (1-p)^{n-j}]
参数:
k array_like
成功数量(双精度),四舍五入到最接近的整数。
n array_like
事件数量(整数)。
p array_like
单次事件成功的概率(浮点数)。
out ndarray,可选
函数值的可选输出数组。
返回:
y 标量或 ndarray。
n 个独立事件中 floor(k) 或更少成功的概率,成功概率为 p。
注意
项没有直接求和;而是根据以下公式使用正则化不完全贝塔函数,
[\mathrm{bdtr}(k, n, p) = I_{1 - p}(n - \lfloor k \rfloor, \lfloor k \rfloor + 1).]
Cephes 的包装器 [1] 例程 bdtr
。
参考文献
[1]
Cephes 数学函数库,www.netlib.org/cephes/
scipy.special.bdtrc
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.bdtrc.html#scipy.special.bdtrc
scipy.special.bdtrc(k, n, p, out=None) = <ufunc 'bdtrc'>
二项分布的生存函数。
floor(k) + 1 到 n 的二项概率密度的项之和,
[\mathrm{bdtrc}(k, n, p) = \sum_{j=\lfloor k \rfloor +1}^n {{n}\choose{j}} p^j (1-p)^{n-j}]
参数:
k array_like
成功次数(double),向下舍入到最近的整数。
n array_like
事件数量(int)
p array_like
单个事件成功的概率。
out ndarray,可选
函数值的可选输出数组
返回:
y 标量或 ndarray
在成功概率为 p 的 n 个独立事件中,floor(k) + 1 或更多次成功的概率。
另请参见
bdtr
betainc
注释
这些项不直接求和;而是根据以下公式使用正则化不完全贝塔函数,
[\mathrm{bdtrc}(k, n, p) = I_{p}(\lfloor k \rfloor + 1, n - \lfloor k \rfloor).]
Cephes [1] 程序的包装器 bdtrc
。
参考文献
[1]
Cephes 数学函数库,www.netlib.org/cephes/
scipy.special.bdtri
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.bdtri.html#scipy.special.bdtri
scipy.special.bdtri(k, n, y, out=None) = <ufunc 'bdtri'>
关于 p 的bdtr
的逆函数。
找到事件概率 p,使得二项概率密度的 0 到 k 项之和等于给定的累积概率 y。
参数:
k数组样式
成功次数(浮点数),向下舍入到最接近的整数。
n数组样式
事件数(浮点数)
y数组样式
累积概率(n 次事件中至多 k 次成功的概率)。
out ndarray,可选
作为函数值的可选输出数组。
返回:
p标量或者数组样式
事件概率,使得 bdtr(lfloor k rfloor, n, p) = y。
另请参见
注释
使用逆贝塔积分函数和关系进行计算,:
1 - p = betaincinv(n - k, k + 1, y).
Cephes 的包装器[1]例程bdtri
。
参考文献
[1]
Cephes 数学函数库,www.netlib.org/cephes/
scipy.special.bdtr
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.bdtr.html#scipy.special.bdtr
scipy.special.bdtr(k, n, p, out=None) = <ufunc 'bdtr'>
二项分布累积分布函数。
二项概率密度的项 0 到floor(k)的总和。
[\mathrm{bdtr}(k, n, p) = \sum_{j=0}^{\lfloor k \rfloor} {{n}\choose{j}} p^j (1-p)^{n-j}]
参数:
k 数组样式
成功次数(双),四舍五入到最接近的整数。
n 数组样式
事件数量(整数)。
p数组样式
单次事件成功的概率(浮点数)。
out ndarray,可选
该函数值的可选输出数组
返回:
y 标量或 ndarray
概率floor(k)或更少成功在n独立事件中,成功概率为p。
注释
项并不直接求和;而是根据公式使用正则化不完全贝塔函数,
[\mathrm{bdtr}(k, n, p) = I_{1 - p}(n - \lfloor k \rfloor, \lfloor k \rfloor + 1).]
Cephes 的包装器[1]例程 bdtr
.
参考文献
[1]
Cephes 数学函数库,www.netlib.org/cephes/
scipy.special.bdtrik
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.bdtrik.html#scipy.special.bdtrik
scipy.special.bdtrik(y, n, p, out=None) = <ufunc 'bdtrik'>
bdtr
关于 k 的反函数。
找到成功次数 k,使得二项概率密度函数对 n 个事件、成功概率 p 的前 k 项之和等于给定的累积概率 y。
参数:
y array_like
累积概率(在 n 次事件中成功 k 次或更少的概率)。
n array_like
事件数(浮点数)。
p array_like
成功概率(浮点数)。
out ndarray,可选
可选的输出数组的函数值
返回:
k 标量或者 ndarray
成功次数 k 满足 bdtr(k, n, p) = y。
参见
bdtr
的反函数。
注意事项
公式 26.5.24 of [1] 用于将二项分布简化为累积不完全贝塔分布。
计算 k 包括搜索能够产生期望的 y 值的数值。搜索依赖于 y 随 k 的单调性。
封装了 CDFLIB [2] Fortran 程序 cdfbin。
参考文献
[1]
Milton Abramowitz 和 Irene A. Stegun 编辑。Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. New York: Dover, 1972.
[2]
Barry Brown, James Lovato, 和 Kathy Russell, CDFLIB: Library of Fortran Routines for Cumulative Distribution Functions, Inverses, and Other Parameters.
scipy.special.bdtr
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.bdtr.html#scipy.special.bdtr
scipy.special.bdtr(k, n, p, out=None) = <ufunc 'bdtr'>
二项分布累积分布函数。
0 到 floor(k) 项的二项概率密度之和。
[\mathrm{bdtr}(k, n, p) = \sum_{j=0}^{\lfloor k \rfloor} {{n}\choose{j}} p^j (1-p)^{n-j}]
参数:
karray_like
成功次数(double),向下取整到最接近的整数。
narray_like
事件数(int)。
parray_like
单次事件成功的概率(float)。
outndarray,可选
函数值的可选输出数组
返回:
y标量或 ndarray
floor(k) 或更少成功的概率,n 个独立事件中的成功概率。
注意事项
这些术语不直接求和;而是根据以下公式使用了正则化的不完全贝塔函数,
[\mathrm{bdtr}(k, n, p) = I_{1 - p}(n - \lfloor k \rfloor, \lfloor k \rfloor + 1).]
Cephes 的封装函数 [1] bdtr
。
参考文献
[1]
Cephes 数学函数库,www.netlib.org/cephes/
scipy.special.bdtrin
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.bdtrin.html#scipy.special.bdtrin
scipy.special.bdtrin(k, y, p, out=None) = <ufunc 'bdtrin'>
关于 n 的 bdtr
的逆函数。
查找事件数量 n,使得二项概率密度函数中第 0 到 k 项的和对应于给定的累积概率 y。
参数:
karray_like
成功次数(浮点数)。
yarray_like
累积概率(在 n 次事件中成功次数不超过 k 的概率)。
parray_like
成功概率(浮点数)。
outndarray,可选
函数值的可选输出数组
返回:
n标量或者 ndarray
事件数量 n,使得 bdtr(k, n, p) = y。
参见
bdtr
注意事项
公式 26.5.24 of [1] 用于将二项分布简化为累积不完全贝塔分布。
计算 n 包括寻找一个值,该值产生所需的 y 值。搜索依赖于 y 随 n 的单调性。
CDFLIB 的包装器 [2] Fortran 例程 cdfbin。
参考文献
[1]
Milton Abramowitz 和 Irene A. Stegun 编,数学函数手册,带有公式、图表和数学表。纽约:Dover,1972。
[2]
Barry Brown,James Lovato 和 Kathy Russell,CDFLIB:Fortran 库例程,用于累积分布函数、逆函数和其他参数。
scipy.special.bdtr
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.bdtr.html#scipy.special.bdtr
scipy.special.bdtr(k, n, p, out=None) = <ufunc 'bdtr'>
二项分布累积分布函数。
二项概率密度从 0 到 k 范围内的术语的总和。
[\mathrm{bdtr}(k, n, p) = \sum_{j=0}^{\lfloor k \rfloor} {{n}\choose{j}} p^j (1-p)^{n-j}]
参数:
karray_like
成功次数(双精度),四舍五入到最接近的整数。
narray_like
事件数量(整数)。
parray_like
单个事件中成功的概率(浮点数)。
outndarray,可选
函数值的可选输出数组
返回:
y标量或 ndarray
k 或更少独立事件中成功的概率,有 n 个事件。
注释
不直接求和术语;而是根据以下公式使用正则化不完全贝塔函数,
[\mathrm{bdtr}(k, n, p) = I_{1 - p}(n - \lfloor k \rfloor, \lfloor k \rfloor + 1).]
Cephes 的包装器 [1] 过程 bdtr
。
参考文献
[1]
Cephes 数学函数库,www.netlib.org/cephes/
scipy.special.btdtr
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.btdtr.html#scipy.special.btdtr
scipy.special.btdtr(a, b, x, out=None)
beta 分布的累积分布函数。
返回 beta 概率密度函数从零到 x 的积分,
[I = \int_0^x \frac{\Gamma(a + b)}{\Gamma(a)\Gamma(b)} t^{a-1} (1-t)^{b-1},dt]
其中 (\Gamma) 是 gamma 函数。
自 1.12.0 版本起已弃用:此函数已弃用,并将在 SciPy 1.14.0 中移除。请改用 scipy.special.betainc
。
参数:
aarray_like
形状参数 (a > 0)。
barray_like
形状参数 (b > 0)。
xarray_like
积分的上限,取值范围为 [0, 1]。
outndarray, 可选
用于函数值的可选输出数组
返回:
I标量或 ndarray
beta 分布的累积分布函数,参数为 a 和 b,在 x 处。
另请参阅
注意事项
此函数与不完全贝塔积分函数 betainc
相同。
参考文献
[1]
Cephes 数学函数库,www.netlib.org/cephes/
scipy.special.btdtri
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.btdtri.html#scipy.special.btdtri
scipy.special.btdtri(a, b, p, out=None)
Beta 分布的第 p 分位数。
此函数是贝塔累积分布函数的反函数,btdtr
,返回满足 btdtr(a, b, x) = p 的 x 值,或
[p = \int_0^x \frac{\Gamma(a + b)}{\Gamma(a)\Gamma(b)} t^{a-1} (1-t)^{b-1},dt]
自 1.12.0 版本起弃用:此函数已弃用,并将在 SciPy 1.14.0 中移除。请使用 scipy.special.betaincinv
替代。
参数:
a array_like
形状参数(a > 0)。
b array_like
形状参数(b > 0)。
p array_like
累积概率,位于 [0, 1] 区间内。
out ndarray,可选
可选的函数值输出数组
返回:
x 标量或 ndarray
对应于 p 的分位数。
另请参阅
betaincinv
btdtr
注意事项
x 的值通过区间二分或牛顿迭代法找到。
Cephes 的包装器[[1]](#r2c6599992aae-1] 路径 incbi,解决了寻找不完整贝塔积分的反函数等价问题。
参考文献
[1]
Cephes 数学函数库, www.netlib.org/cephes/
scipy.special.btdtria
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.btdtria.html#scipy.special.btdtria
scipy.special.btdtria(p, b, x, out=None) = <ufunc 'btdtria'>
与 a 相关的btdtr
的反函数。
这是贝塔累积分布函数btdtr
的反函数,作为关于 a 的函数,返回使得 btdtr(a, b, x) = p 的 a 的值,或
[p = \int_0^x \frac{\Gamma(a + b)}{\Gamma(a)\Gamma(b)} t^{a-1} (1-t)^{b-1},dt]
参数:
parray_like
累积概率,在[0, 1]之间。
barray_like
形状参数(b > 0)。
xarray_like
分位数,在[0, 1]之间。
outndarray,可选
用于函数值的可选输出数组
返回:
a标量或 ndarray
形状参数 a 的值,使得 btdtr(a, b, x) = p。
另请参阅
贝塔分布的累积分布函数。
关于 x 的反函数。
关于 b 的反函数。
注意事项
CDFLIB 的 C 语言库的包装器[1] Fortran 例程cdfbet。
使用 DiDinato 和 Morris 的例程[2]计算累积分布函数 p。计算 a 包括搜索产生期望 p 值的值的过程。搜索依赖于 p 随 a 的单调性。
参考文献
[1]
Barry Brown, James Lovato 和 Kathy Russell,CDFLIB:用于累积分布函数、反函数和其他参数的 Fortran 例程库。
[2]
DiDinato, A. R.和 Morris, A. H.,算法 708:不完全贝塔函数比的有效数字计算。ACM Trans. Math. Softw. 18 (1993), 360-373。
scipy.special.btdtr
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.btdtr.html#scipy.special.btdtr
scipy.special.btdtr(a, b, x, out=None)
贝塔分布的累积分布函数。
返回从零到x的贝塔概率密度函数的积分,
[I = \int_0^x \frac{\Gamma(a + b)}{\Gamma(a)\Gamma(b)} t^{a-1} (1-t)^{b-1},dt]
其中(\Gamma)是伽玛函数。
自 1.12.0 版本起不推荐使用:此函数已被弃用,并将在 SciPy 1.14.0 中删除。请改用scipy.special.betainc
。
参数:
aarray_like
形状参数(a > 0)。
barray_like
形状参数(b > 0)。
xarray_like
积分的上限,在[0, 1]之间。
outndarray,可选
可选的输出数组,用于函数值
返回:
I标量或 ndarray
贝塔分布的累积分布函数,参数为a和b,在x处。
另请参阅
betainc
注意事项
此函数与不完全贝塔积分函数betainc
完全相同。
Cephes 的包装器[1]例程btdtr
。
参考文献
[1]
Cephes 数学函数库,www.netlib.org/cephes/
scipy.special.btdtrib
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.btdtrib.html#scipy.special.btdtrib
scipy.special.btdtrib(a, p, x, out=None) = <ufunc 'btdtrib'>
相对于 b 的 btdtr
的逆。
这是 beta 累积分布函数的逆,btdtr
作为 b 的函数,返回使 btdtr(a, b, x) = p 的 b 的值,或者
[p = \int_0^x \frac{\Gamma(a + b)}{\Gamma(a)\Gamma(b)} t^{a-1} (1-t)^{b-1},dt]
参数:
aarray_like
形状参数(a > 0)。
parray_like
累积概率,在 [0, 1] 区间内。
xarray_like
分位数,在 [0, 1] 区间内。
outndarray, optional
可选输出数组用于函数值
返回:
bscalar 或 ndarray
形状参数 b 的值,使得 btdtr(a, b, x) = p。
另请参见
btdtr
beta 分布的累积分布函数。
btdtri
相对于 x 的逆。
btdtria
相对于 a 的逆。
注意事项
CDFLIB 的 C 语言库包装器 [1] Fortran routine cdfbet。
使用 DiDinato 和 Morris 的例程计算累积分布函数 p [2]。计算 b 涉及搜索产生所需 p 值的值。搜索依赖于 p 随 b 的单调性。
参考资料
[1]
Barry Brown, James Lovato 和 Kathy Russell, CDFLIB: 用于累积分布函数、逆函数和其他参数的 Fortran 例程库。
[2]
DiDinato, A. R. 和 Morris, A. H., Algorithm 708: Incomplete Beta Function Ratios 的有效数字计算。ACM Trans. Math. Softw. 18 (1993), 360-373.
scipy.special.btdtr
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.btdtr.html#scipy.special.btdtr
scipy.special.btdtr(a, b, x, out=None)
贝塔分布的累积分布函数。
返回从零到x的贝塔概率密度函数的积分,
[I = \int_0^x \frac{\Gamma(a + b)}{\Gamma(a)\Gamma(b)} t^{a-1} (1-t)^{b-1},dt]
其中(\Gamma)是 Gamma 函数。
自 SciPy 1.12.0 版本起弃用:此函数已弃用,将在 SciPy 1.14.0 中移除。请使用scipy.special.betainc
代替。
参数:
a类似数组
形状参数(a > 0)。
b类似数组
形状参数(b > 0)。
x类似数组
积分的上限,位于[0, 1]内。
out数组,可选
函数值的可选输出数组
返回:
I标量或类似数组
在x处参数为a和b的贝塔分布的累积分布函数。
另请参阅
betainc
,这是不完全贝塔积分函数的别名。
注释
此函数与不完全贝塔积分函数betainc
完全相同。
Cephes 库的包装器[1] btdtr
例程。
参考文献
Cephes 数学函数库,www.netlib.org/cephes/
scipy.special.fdtr
原文链接:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.fdtr.html#scipy.special.fdtr
scipy.special.fdtr(dfn, dfd, x, out=None) = <ufunc 'fdtr'>
F 累积分布函数。
返回 F 分布的累积分布函数值,也称为 Snedecor's F 分布或 Fisher-Snedecor 分布。
具有参数(d_n)和(d_d)的 F 分布是随机变量的分布,
[X = \frac{U_n/d_n}{U_d/d_d},]
其中(U_n)和(U_d)是分布为(\chi²)的随机变量,分别具有(d_n)和(d_d)自由度。
参数:
dfnarray_like
第一个参数(正浮点数)。
dfdarray_like
第二个参数(正浮点数)。
xarray_like
参数(非负浮点数)。
输出ndarray,可选
函数值的可选输出数组
返回:
y标量或 ndarray
在x处具有参数dfn和dfd的 F 分布的累积分布函数。
参见
fdtrc
F 分布生存函数
fdtri
F 分布反函数累积分布
scipy.stats.f
F 分布
注意事项
根据公式使用正则化的不完全贝塔函数,
[F(d_n, d_d; x) = I_{xd_n/(d_d + xd_n)}(d_n/2, d_d/2).]
包装器用于 Cephes [1] 程序 fdtr
。 F 分布也可作为 scipy.stats.f
。 直接调用 fdtr
相比 scipy.stats.f
的 cdf
方法可以提高性能(请参见下面的最后一个示例)。
参考文献
[1]
Cephes 数学函数库,www.netlib.org/cephes/
示例
计算dfn=1
和dfd=2
在x=1
时的函数。
>>> import numpy as np
>>> from scipy.special import fdtr
>>> fdtr(1, 2, 1)
0.5773502691896258
通过为x提供一个 NumPy 数组来计算几个点上的函数。
>>> x = np.array([0.5, 2., 3.])
>>> fdtr(1, 2, x)
array([0.4472136 , 0.70710678, 0.77459667])
绘制几组参数集的函数图。
>>> import matplotlib.pyplot as plt
>>> dfn_parameters = [1, 5, 10, 50]
>>> dfd_parameters = [1, 1, 2, 3]
>>> linestyles = ['solid', 'dashed', 'dotted', 'dashdot']
>>> parameters_list = list(zip(dfn_parameters, dfd_parameters,
... linestyles))
>>> x = np.linspace(0, 30, 1000)
>>> fig, ax = plt.subplots()
>>> for parameter_set in parameters_list:
... dfn, dfd, style = parameter_set
... fdtr_vals = fdtr(dfn, dfd, x)
... ax.plot(x, fdtr_vals, label=rf"$d_n={dfn},\, d_d={dfd}$",
... ls=style)
>>> ax.legend()
>>> ax.set_xlabel("$x$")
>>> ax.set_title("F distribution cumulative distribution function")
>>> plt.show()
F 分布也可以作为 scipy.stats.f
。 对于小数组或单个值,直接使用 fdtr
可能比调用 scipy.stats.f
的 cdf
方法快得多。 要获得相同的结果,必须使用以下参数化:stats.f(dfn, dfd).cdf(x)=fdtr(dfn, dfd, x)
。
>>> from scipy.stats import f
>>> dfn, dfd = 1, 2
>>> x = 1
>>> fdtr_res = fdtr(dfn, dfd, x) # this will often be faster than below
>>> f_dist_res = f(dfn, dfd).cdf(x)
>>> fdtr_res == f_dist_res # test that results are equal
True
scipy.special.fdtrc
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.fdtrc.html#scipy.special.fdtrc
scipy.special.fdtrc(dfn, dfd, x, out=None) = <ufunc 'fdtrc'>
F 生存函数。
返回补充 F 分布函数(从 x 到无穷的密度积分)。
参数:
dfn array_like
第一个参数(正浮点数)。
dfd array_like
第二个参数(正浮点数)。
x array_like
参数(非负浮点数)。
out ndarray,可选
函数值的可选输出数组
返回:
y 标量或者 ndarray
补充 F 分布函数,带有参数 dfn 和 dfd 在 x 处。
另请参阅
F 分布的累积分布函数
F 分布的逆累积分布函数
F 分布
注意
根据公式使用常规不完全 Beta 函数,
[F(d_n, d_d; x) = I_{d_d/(d_d + xd_n)}(d_d/2, d_n/2).]
Cephes 的包装器[1],使用 Cephes 中的 fdtrc
程序。F 分布也可作为 scipy.stats.f
调用。直接调用 fdtrc
可以提高性能,与 scipy.stats.f
的 sf
方法相比(请参阅下面的最后一个示例)。
参考文献
[1]
Cephes 数学函数库,www.netlib.org/cephes/
示例
计算dfn=1
和dfd=2
在x=1
时的函数。
>>> import numpy as np
>>> from scipy.special import fdtrc
>>> fdtrc(1, 2, 1)
0.42264973081037427
通过为 x 提供 NumPy 数组在几个点上计算函数。
>>> x = np.array([0.5, 2., 3.])
>>> fdtrc(1, 2, x)
array([0.5527864 , 0.29289322, 0.22540333])
绘制几个参数集的函数。
>>> import matplotlib.pyplot as plt
>>> dfn_parameters = [1, 5, 10, 50]
>>> dfd_parameters = [1, 1, 2, 3]
>>> linestyles = ['solid', 'dashed', 'dotted', 'dashdot']
>>> parameters_list = list(zip(dfn_parameters, dfd_parameters,
... linestyles))
>>> x = np.linspace(0, 30, 1000)
>>> fig, ax = plt.subplots()
>>> for parameter_set in parameters_list:
... dfn, dfd, style = parameter_set
... fdtrc_vals = fdtrc(dfn, dfd, x)
... ax.plot(x, fdtrc_vals, label=rf"$d_n={dfn},\, d_d={dfd}$",
... ls=style)
>>> ax.legend()
>>> ax.set_xlabel("$x$")
>>> ax.set_title("F distribution survival function")
>>> plt.show()
F 分布也可作为 scipy.stats.f
调用。直接使用 fdtrc
可比调用 scipy.stats.f
的 sf
方法更快,特别是对于小数组或单个值。为了获得相同的结果,必须使用以下参数化方式:stats.f(dfn, dfd).sf(x)=fdtrc(dfn, dfd, x)
。
>>> from scipy.stats import f
>>> dfn, dfd = 1, 2
>>> x = 1
>>> fdtrc_res = fdtrc(dfn, dfd, x) # this will often be faster than below
>>> f_dist_res = f(dfn, dfd).sf(x)
>>> f_dist_res == fdtrc_res # test that results are equal
True
scipy.special.fdtri
原文:
docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.special.fdtri.html#scipy.special.fdtri
scipy.special.fdtri(dfn, dfd, p, out=None) = <ufunc 'fdtri'>
F 分布的p-th 分位数。
该函数是 F 分布 CDF 的逆函数,fdtr
,返回x,使得fdtr(dfn, dfd, x) = p。
参数:
dfn类似数组
第一个参数(正浮点数)。
dfd类似数组
第二个参数(正浮点数)。
p类似数组
累积概率,在[0, 1]区间内。
out ndarray,可选
函数值的可选输出数组
返回:
x标量或 ndarray
p对应的分位数。
另请参见
fdtr
F 分布累积分布函数
fdtrc
F 分布生存函数
scipy.stats.f
F 分布
注意事项
计算是通过与逆正则化贝塔函数的关系进行的,即(I^{-1}_x(a, b))。令(z = I^{-1}_p(d_d/2, d_n/2))。然后,
[x = \frac{d_d (1 - z)}{d_n z}.]
如果p使得(x < 0.5),则改为使用以下关系以提高稳定性:令(z' = I^{-1}_{1 - p}(d_n/2, d_d/2))。然后,
[x = \frac{d_d z'}{d_n (1 - z')}.]
Cephes 的包装器[1]函数fdtri
。
F 分布同样可以作为scipy.stats.f
获取。直接调用fdtri
相比scipy.stats.f
的ppf
方法可以提高性能(见下面的最后一个示例)。
参考
[1]
Cephes 数学函数库,www.netlib.org/cephes/
示例
fdtri
表示 F 分布 CDF 的逆函数,可以作为fdtr
获得。在这里,我们计算df1=1
,df2=2
时在x=3
处的 CDF。fdtri
然后返回3
,给定相同的df1,df2和计算的 CDF 值。
>>> import numpy as np
>>> from scipy.special import fdtri, fdtr
>>> df1, df2 = 1, 2
>>> x = 3
>>> cdf_value = fdtr(df1, df2, x)
>>> fdtri(df1, df2, cdf_value)
3.000000000000006
通过为x提供一个 NumPy 数组,在几个点上计算函数。
>>> x = np.array([0.1, 0.4, 0.7])
>>> fdtri(1, 2, x)
array([0.02020202, 0.38095238, 1.92156863])
绘制几个参数集的函数图。
>>> import matplotlib.pyplot as plt
>>> dfn_parameters = [50, 10, 1, 50]
>>> dfd_parameters = [0.5, 1, 1, 5]
>>> linestyles = ['solid', 'dashed', 'dotted', 'dashdot']
>>> parameters_list = list(zip(dfn_parameters, dfd_parameters,
... linestyles))
>>> x = np.linspace(0, 1, 1000)
>>> fig, ax = plt.subplots()
>>> for parameter_set in parameters_list:
... dfn, dfd, style = parameter_set
... fdtri_vals = fdtri(dfn, dfd, x)
... ax.plot(x, fdtri_vals, label=rf"$d_n={dfn},\, d_d={dfd}$",
... ls=style)
>>> ax.legend()
>>> ax.set_xlabel("$x$")
>>> title = "F distribution inverse cumulative distribution function"
>>> ax.set_title(title)
>>> ax.set_ylim(0, 30)
>>> plt.show()
F 分布也可以通过 scipy.stats.f
获得。直接使用 fdtri
可比调用 scipy.stats.f
的 ppf
方法要快得多,特别是对于小数组或单个值。要获得相同的结果,必须使用以下参数化形式:stats.f(dfn, dfd).ppf(x)=fdtri(dfn, dfd, x)
。
>>> from scipy.stats import f
>>> dfn, dfd = 1, 2
>>> x = 0.7
>>> fdtri_res = fdtri(dfn, dfd, x) # this will often be faster than below
>>> f_dist_res = f(dfn, dfd).ppf(x)
>>> f_dist_res == fdtri_res # test that results are equal
True
scipy.special.fdtri
scipy.special.fdtridfd(dfn, p, x, out=None) = <ufunc 'fdtridfd'>
与 fdtr
相反的 dfd
找到 F 密度参数 dfd
,使得 fdtr(dfn, dfd, x) == p
。
参数:
dfn 数组样式
第一个参数(正浮点数)。
p 数组样式
累积概率,在 [0, 1] 区间内。
x 数组样式
参数(非负浮点数)。
out ndarray,可选
函数值的可选输出数组
返回:
dfd 标量或 ndarray
dfd,使得 fdtr(dfn, dfd, x) == p
。
另请参阅
F 分布累积分布函数
F 分布生存函数
F 分布分位函数
F 分布
示例
计算一个参数集的 F 分布累积分布函数。
>>> from scipy.special import fdtridfd, fdtr
>>> dfn, dfd, x = 10, 5, 2
>>> cdf_value = fdtr(dfn, dfd, x)
>>> cdf_value
0.7700248806501017
验证 fdtridfd
能够恢复 dfd 的原始值:
>>> fdtridfd(dfn, cdf_value, x)
5.0