本文整理汇总了Python中scipy.special.expn方法的典型用法代码示例。如果您正苦于以下问题:Python special.expn方法的具体用法?Python special.expn怎么用?Python special.expn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.special
的用法示例。
在下文中一共展示了special.expn方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_legacy
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import expn [as 别名]
def test_legacy():
warn_ctx = WarningManager()
warn_ctx.__enter__()
try:
warnings.simplefilter("ignore", RuntimeWarning)
# Legacy behavior: truncating arguments to integers
assert_equal(special.bdtrc(1, 2, 0.3), special.bdtrc(1.8, 2.8, 0.3))
assert_equal(special.bdtr(1, 2, 0.3), special.bdtr(1.8, 2.8, 0.3))
assert_equal(special.bdtri(1, 2, 0.3), special.bdtri(1.8, 2.8, 0.3))
assert_equal(special.expn(1, 0.3), special.expn(1.8, 0.3))
assert_equal(special.hyp2f0(1, 2, 0.3, 1), special.hyp2f0(1, 2, 0.3, 1.8))
assert_equal(special.nbdtrc(1, 2, 0.3), special.nbdtrc(1.8, 2.8, 0.3))
assert_equal(special.nbdtr(1, 2, 0.3), special.nbdtr(1.8, 2.8, 0.3))
assert_equal(special.nbdtri(1, 2, 0.3), special.nbdtri(1.8, 2.8, 0.3))
assert_equal(special.pdtrc(1, 0.3), special.pdtrc(1.8, 0.3))
assert_equal(special.pdtr(1, 0.3), special.pdtr(1.8, 0.3))
assert_equal(special.pdtri(1, 0.3), special.pdtri(1.8, 0.3))
assert_equal(special.kn(1, 0.3), special.kn(1.8, 0.3))
assert_equal(special.yn(1, 0.3), special.yn(1.8, 0.3))
assert_equal(special.smirnov(1, 0.3), special.smirnov(1.8, 0.3))
assert_equal(special.smirnovi(1, 0.3), special.smirnovi(1.8, 0.3))
finally:
warn_ctx.__exit__()
示例2: test_legacy
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import expn [as 别名]
def test_legacy():
# Legacy behavior: truncating arguments to integers
with suppress_warnings() as sup:
sup.filter(RuntimeWarning, "floating point number truncated to an integer")
assert_equal(special.bdtrc(1, 2, 0.3), special.bdtrc(1.8, 2.8, 0.3))
assert_equal(special.bdtr(1, 2, 0.3), special.bdtr(1.8, 2.8, 0.3))
assert_equal(special.bdtri(1, 2, 0.3), special.bdtri(1.8, 2.8, 0.3))
assert_equal(special.expn(1, 0.3), special.expn(1.8, 0.3))
assert_equal(special.hyp2f0(1, 2, 0.3, 1), special.hyp2f0(1, 2, 0.3, 1.8))
assert_equal(special.nbdtrc(1, 2, 0.3), special.nbdtrc(1.8, 2.8, 0.3))
assert_equal(special.nbdtr(1, 2, 0.3), special.nbdtr(1.8, 2.8, 0.3))
assert_equal(special.nbdtri(1, 2, 0.3), special.nbdtri(1.8, 2.8, 0.3))
assert_equal(special.pdtrc(1, 0.3), special.pdtrc(1.8, 0.3))
assert_equal(special.pdtr(1, 0.3), special.pdtr(1.8, 0.3))
assert_equal(special.pdtri(1, 0.3), special.pdtri(1.8, 0.3))
assert_equal(special.kn(1, 0.3), special.kn(1.8, 0.3))
assert_equal(special.yn(1, 0.3), special.yn(1.8, 0.3))
assert_equal(special.smirnov(1, 0.3), special.smirnov(1.8, 0.3))
assert_equal(special.smirnovi(1, 0.3), special.smirnovi(1.8, 0.3))
示例3: inc_gamma
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import expn [as 别名]
def inc_gamma(s, x):
r"""The (upper) incomplete gamma function.
Given by: :math:`\Gamma(s,x) = \int_x^{\infty} t^{s-1}\,e^{-t}\,{\rm d}t`
Parameters
----------
s : :class:`float`
exponent in the integral
x : :class:`numpy.ndarray`
input values
"""
if np.isclose(s, 0):
return sps.exp1(x)
if np.isclose(s, np.around(s)) and s < -0.5:
return x ** (s - 1) * sps.expn(int(1 - np.around(s)), x)
if s < 0:
return (inc_gamma(s + 1, x) - x ** s * np.exp(-x)) / s
return sps.gamma(s) * sps.gammaincc(s, x)
示例4: _entropy
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import expn [as 别名]
def _entropy(self, c):
return 1.0 - np.log(c) - np.exp(c)*sc.expn(1, c)
示例5: test_expn
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import expn [as 别名]
def test_expn(self):
cephes.expn(1,1)
示例6: test_expint
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import expn [as 别名]
def test_expint(self):
assert_mpmath_equal(sc.expn,
_exception_to_nan(mpmath.expint),
[IntArg(0, 100), Arg()])
示例7: test_expi_complex
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import expn [as 别名]
def test_expi_complex():
dataset = []
for r in np.logspace(-99, 2, 10):
for p in np.linspace(0, 2*np.pi, 30):
z = r*np.exp(1j*p)
dataset.append((z, complex(mpmath.ei(z))))
dataset = np.array(dataset, dtype=np.complex_)
FuncData(sc.expi, dataset, 0, 1).check()
# ------------------------------------------------------------------------------
# expn
# ------------------------------------------------------------------------------
示例8: test_expn_large_n
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import expn [as 别名]
def test_expn_large_n():
# Test the transition to the asymptotic regime of n.
dataset = []
for n in [50, 51]:
for x in np.logspace(0, 4, 200):
with mpmath.workdps(100):
dataset.append((n, x, float(mpmath.expint(n, x))))
dataset = np.asarray(dataset)
FuncData(sc.expn, dataset, (0, 1), 2, rtol=1e-13).check()
# ------------------------------------------------------------------------------
# hyp0f1
# ------------------------------------------------------------------------------
示例9: exp_int
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import expn [as 别名]
def exp_int(s, x):
r"""The exponential integral :math:`E_s(x)`.
Given by: :math:`E_s(x) = \int_1^\infty \frac{e^{-xt}}{t^s}\,\mathrm dt`
Parameters
----------
s : :class:`float`
exponent in the integral (should be > -100)
x : :class:`numpy.ndarray`
input values
"""
if np.isclose(s, 1):
return sps.exp1(x)
if np.isclose(s, np.around(s)) and s > -0.5:
return sps.expn(int(np.around(s)), x)
x = np.array(x, dtype=np.double)
x_neg = x < 0
x = np.abs(x)
x_compare = x ** min((10, max(((1 - s), 1))))
res = np.empty_like(x)
# use asymptotic behavior for zeros
x_zero = np.isclose(x_compare, 0, atol=1e-20)
x_inf = x > max(30, -s / 2) # function is like exp(-x)*(1/x + s/x^2)
x_fin = np.logical_not(np.logical_or(x_zero, x_inf))
x_fin_pos = np.logical_and(x_fin, np.logical_not(x_neg))
if s > 1.0: # limit at x=+0
res[x_zero] = 1.0 / (s - 1.0)
else:
res[x_zero] = np.inf
res[x_inf] = np.exp(-x[x_inf]) * (x[x_inf] ** -1 - s * x[x_inf] ** -2)
res[x_fin_pos] = inc_gamma(1 - s, x[x_fin_pos]) * x[x_fin_pos] ** (s - 1)
res[x_neg] = np.nan # nan for x < 0
return res