本文整理汇总了Python中scipy.special.hyp1f1方法的典型用法代码示例。如果您正苦于以下问题:Python special.hyp1f1方法的具体用法?Python special.hyp1f1怎么用?Python special.hyp1f1使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.special
的用法示例。
在下文中一共展示了special.hyp1f1方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _pdf
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import hyp1f1 [as 别名]
def _pdf(self, x, df, nc):
# nct.pdf(x, df, nc) =
# df**(df/2) * gamma(df+1)
# ----------------------------------------------------
# 2**df*exp(nc**2/2) * (df+x**2)**(df/2) * gamma(df/2)
n = df*1.0
nc = nc*1.0
x2 = x*x
ncx2 = nc*nc*x2
fac1 = n + x2
trm1 = n/2.*np.log(n) + sc.gammaln(n+1)
trm1 -= n*np.log(2)+nc*nc/2.+(n/2.)*np.log(fac1)+sc.gammaln(n/2.)
Px = np.exp(trm1)
valF = ncx2 / (2*fac1)
trm1 = np.sqrt(2)*nc*x*sc.hyp1f1(n/2+1, 1.5, valF)
trm1 /= np.asarray(fac1*sc.gamma((n+1)/2))
trm2 = sc.hyp1f1((n+1)/2, 0.5, valF)
trm2 /= np.asarray(np.sqrt(fac1)*sc.gamma(n/2+1))
Px *= trm1+trm2
return Px
示例2: __call__
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import hyp1f1 [as 别名]
def __call__(self, n, **kwargs):
r""" The Watson spherical distribution model [1, 2].
Parameters
----------
n : array of shape(3) or array of shape(N x 3),
sampled orientations of the Watson distribution.
Returns
-------
Wn: float or array of shape(N),
Probability density at orientations n, given mu and kappa.
"""
odi = kwargs.get('odi', self.odi)
mu = kwargs.get('mu', self.mu)
kappa = odi2kappa(odi)
mu_cart = utils.unitsphere2cart_1d(mu)
numerator = np.exp(kappa * np.dot(n, mu_cart) ** 2)
denominator = 4 * np.pi * special.hyp1f1(0.5, 1.5, kappa)
Wn = numerator / denominator
return Wn
示例3: _pdf
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import hyp1f1 [as 别名]
def _pdf(self, x, df, nc):
n = df*1.0
nc = nc*1.0
x2 = x*x
ncx2 = nc*nc*x2
fac1 = n + x2
trm1 = n/2.*np.log(n) + sc.gammaln(n+1)
trm1 -= n*np.log(2)+nc*nc/2.+(n/2.)*np.log(fac1)+sc.gammaln(n/2.)
Px = np.exp(trm1)
valF = ncx2 / (2*fac1)
trm1 = np.sqrt(2)*nc*x*sc.hyp1f1(n/2+1, 1.5, valF)
trm1 /= np.asarray(fac1*sc.gamma((n+1)/2))
trm2 = sc.hyp1f1((n+1)/2, 0.5, valF)
trm2 /= np.asarray(np.sqrt(fac1)*sc.gamma(n/2+1))
Px *= trm1+trm2
return Px
示例4: _munp
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import hyp1f1 [as 别名]
def _munp(self, n, dfn, dfd, nc):
val = (dfn * 1.0/dfd)**n
term = sc.gammaln(n+0.5*dfn) + sc.gammaln(0.5*dfd-n) - sc.gammaln(dfd*0.5)
val *= np.exp(-nc / 2.0+term)
val *= sc.hyp1f1(n+0.5*dfn, 0.5*dfn, 0.5*nc)
return val
示例5: test_hyp1f1
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import hyp1f1 [as 别名]
def test_hyp1f1(self):
assert_approx_equal(cephes.hyp1f1(1,1,1), exp(1.0))
assert_approx_equal(cephes.hyp1f1(3,4,-6), 0.026056422099537251095)
cephes.hyp1f1(1,1,1)
示例6: test_hyperu
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import hyp1f1 [as 别名]
def test_hyperu(self):
val1 = special.hyperu(1,0.1,100)
assert_almost_equal(val1,0.0098153,7)
a,b = [0.3,0.6,1.2,-2.7],[1.5,3.2,-0.4,-3.2]
a,b = asarray(a), asarray(b)
z = 0.5
hypu = special.hyperu(a,b,z)
hprl = (pi/sin(pi*b))*(special.hyp1f1(a,b,z) /
(special.gamma(1+a-b)*special.gamma(b)) -
z**(1-b)*special.hyp1f1(1+a-b,2-b,z)
/ (special.gamma(a)*special.gamma(2-b)))
assert_array_almost_equal(hypu,hprl,12)
示例7: test_hyp1f1
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import hyp1f1 [as 别名]
def test_hyp1f1(self):
assert_mpmath_equal(_inf_to_nan(sc.hyp1f1),
_exception_to_nan(lambda a, b, x: mpmath.hyp1f1(a, b, x, **HYPERKW)),
[Arg(-1e5, 1e5), Arg(-1e5, 1e5), Arg()],
n=2000)
示例8: test_hyp1f1_complex
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import hyp1f1 [as 别名]
def test_hyp1f1_complex(self):
assert_mpmath_equal(_inf_to_nan(lambda a, b, x: sc.hyp1f1(a.real, b.real, x)),
_exception_to_nan(lambda a, b, x: mpmath.hyp1f1(a, b, x, **HYPERKW)),
[Arg(-1e3, 1e3), Arg(-1e3, 1e3), ComplexArg()],
n=2000)
示例9: dDphi_dz
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import hyp1f1 [as 别名]
def dDphi_dz(self, r, phi, phi_q, wavelength):
"""differential contribution to the phase structure function
"""
return 4.0 * (wavelength/self.wavelength_reference)**2 * self.C_scatt_0/self.scatt_alpha * (sps.hyp1f1(-self.scatt_alpha/2.0, 0.5, -r**2/(4.0*self.r_in**2)*np.cos(phi - phi_q)**2) - 1.0)
示例10: test_hyp1f1_gh2957
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import hyp1f1 [as 别名]
def test_hyp1f1_gh2957(self):
hyp1 = special.hyp1f1(0.5, 1.5, -709.7827128933)
hyp2 = special.hyp1f1(0.5, 1.5, -709.7827128934)
assert_almost_equal(hyp1, hyp2, 12)
示例11: test_hyp1f1
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import hyp1f1 [as 别名]
def test_hyp1f1(self):
assert_mpmath_equal(inf_to_nan(sc.hyp1f1),
exception_to_nan(lambda a, b, x: mpmath.hyp1f1(a, b, x, **HYPERKW)),
[Arg(-1e5, 1e5), Arg(-1e5, 1e5), Arg()],
n=2000)
示例12: test_hyp1f1_complex
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import hyp1f1 [as 别名]
def test_hyp1f1_complex(self):
assert_mpmath_equal(inf_to_nan(lambda a, b, x: sc.hyp1f1(a.real, b.real, x)),
exception_to_nan(lambda a, b, x: mpmath.hyp1f1(a, b, x, **HYPERKW)),
[Arg(-1e3, 1e3), Arg(-1e3, 1e3), ComplexArg()],
n=2000)
示例13: pr
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import hyp1f1 [as 别名]
def pr(u, x):
if u == 0:
out = 1.0 * np.exp(-x)
else:
out = 1.0 * x * np.exp(2*-x) * (2**-u) * spc.hyp1f1(u + 1, 2, x)
return out
示例14: log_norm_1f1
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import hyp1f1 [as 别名]
def log_norm_1f1(scale, dimension):
# This is already good.
# I am unsure if the others are better.
# In https://github.com/scipy/scipy/issues/2957
# is denoted that they solved a precision issue
# With scale > 800 this function makes problems.
# Normally scale is thresholded by 100
norm = hyp1f1(1, dimension, scale) * (
2 * np.pi ** dimension / math.factorial(dimension - 1)
)
return np.log(norm)
示例15: hypergeometric_ratio
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import hyp1f1 [as 别名]
def hypergeometric_ratio(self, concentration):
eigenvalue = hyp1f1(2, self.dimension + 1, concentration) / (
self.dimension * hyp1f1(1, self.dimension, concentration)
)
return eigenvalue