本文整理汇总了Python中scipy.special.betainc方法的典型用法代码示例。如果您正苦于以下问题:Python special.betainc方法的具体用法?Python special.betainc怎么用?Python special.betainc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.special
的用法示例。
在下文中一共展示了special.betainc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compute_corr_significance
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import betainc [as 别名]
def compute_corr_significance(r, N):
""" Compute statistical significance for a pearson correlation between
two xarray objects.
Parameters
----------
r : `xarray.DataArray` object
correlation coefficient between two time series.
N : int
length of time series being correlated.
Returns
-------
pval : float
p value for pearson correlation.
"""
df = N - 2
t_squared = r ** 2 * (df / ((1.0 - r) * (1.0 + r)))
# method used in scipy, where `np.fmin` constrains values to be
# below 1 due to errors in floating point arithmetic.
pval = special.betainc(0.5 * df, 0.5, np.fmin(df / (df + t_squared), 1.0))
return xr.DataArray(pval, coords=t_squared.coords, dims=t_squared.dims)
示例2: bdtrc
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import betainc [as 别名]
def bdtrc(k, n, p):
if (k < 0):
return (1.0)
if (k == n):
return (0.0)
dn = n - k
if (k == 0):
if (p < .01):
dk = -np.expm1(dn * np.log1p(-p))
else:
dk = 1.0 - np.exp(dn * np.log(1.0 - p))
else:
dk = k + 1
dk = betainc(dk, dn, p)
return dk
示例3: _betai
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import betainc [as 别名]
def _betai(a, b, x):
x = np.asarray(x)
x = np.where(x < 1.0, x, 1.0) # if x > 1 then return 1.0
return special.betainc(a, b, x)
#####################################
# STATISTICAL DISTANCES #
#####################################
示例4: _betai
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import betainc [as 别名]
def _betai(a, b, x):
x = np.asanyarray(x)
x = ma.where(x < 1.0, x, 1.0) # if x > 1 then return 1.0
return special.betainc(a, b, x)
示例5: _cdf
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import betainc [as 别名]
def _cdf(self, x, n, p):
k = floor(x)
return special.betainc(n, k+1, p)
示例6: betai
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import betainc [as 别名]
def betai(a, b, x):
"""
Returns the incomplete beta function.
I_x(a,b) = 1/B(a,b)*(Integral(0,x) of t^(a-1)(1-t)^(b-1) dt)
where a,b>0 and B(a,b) = G(a)*G(b)/(G(a+b)) where G(a) is the gamma
function of a.
The standard broadcasting rules apply to a, b, and x.
Parameters
----------
a : array_like or float > 0
b : array_like or float > 0
x : array_like or float
x will be clipped to be no greater than 1.0 .
Returns
-------
betai : ndarray
Incomplete beta function.
"""
x = np.asarray(x)
x = np.where(x < 1.0, x, 1.0) # if x > 1 then return 1.0
return special.betainc(a, b, x)
#####################################
####### ANOVA CALCULATIONS #######
#####################################
示例7: betai
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import betainc [as 别名]
def betai(a, b, x):
x = np.asanyarray(x)
x = ma.where(x < 1.0, x, 1.0) # if x > 1 then return 1.0
return special.betainc(a, b, x)
示例8: test_betainc
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import betainc [as 别名]
def test_betainc(self):
assert_equal(cephes.betainc(1,1,1),1.0)
示例9: test_betaincinv
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import betainc [as 别名]
def test_betaincinv(self):
y = special.betaincinv(2,4,.5)
comp = special.betainc(2,4,y)
assert_almost_equal(comp,.5,5)
示例10: cdf
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import betainc [as 别名]
def cdf(self, pX, pR, pP):
"""
Cumulative density function of a continuous generalization of NB distribution
"""
# if pX == 0:
# return 0
return special.betainc(pR, pX + 1, pP)
示例11: check_sample_mean
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import betainc [as 别名]
def check_sample_mean(sm, v, n, popmean):
# from stats.stats.ttest_1samp(a, popmean):
# Calculates the t-obtained for the independent samples T-test on ONE group
# of scores a, given a population mean.
#
# Returns: t-value, two-tailed prob
df = n-1
svar = ((n-1)*v) / float(df) # looks redundant
t = (sm-popmean) / np.sqrt(svar*(1.0/n))
prob = betainc(0.5*df, 0.5, df/(df + t*t))
# return t,prob
npt.assert_(prob > 0.01, 'mean fail, t,prob = %f, %f, m, sm=%f,%f' %
(t, prob, popmean, sm))
示例12: test_betainc
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import betainc [as 别名]
def test_betainc(self):
assert_equal(cephes.betainc(1,1,1),1.0)
assert_allclose(cephes.betainc(0.0342, 171, 1e-10), 0.55269916901806648)
示例13: inc_beta
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import betainc [as 别名]
def inc_beta(a, b, x):
r"""The incomplete Beta function.
Given by: :math:`B(a,b;\,x) = \int_0^x t^{a-1}\,(1-t)^{b-1}\,dt`
Parameters
----------
a : :class:`float`
first exponent in the integral
b : :class:`float`
second exponent in the integral
x : :class:`numpy.ndarray`
input values
"""
return sps.betainc(a, b, x) * sps.beta(a, b)
示例14: corrcoef_matrix
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import betainc [as 别名]
def corrcoef_matrix(matrix):
# Code originating from http://stackoverflow.com/a/24547964 by http://stackoverflow.com/users/2455058/jingchao
r = np.corrcoef(matrix)
rf = r[np.triu_indices(r.shape[0], 1)]
df = matrix.shape[1] - 2
ts = rf * rf * (df / (1 - rf * rf))
pf = betainc(0.5 * df, 0.5, df / (df + ts))
p = np.zeros(shape=r.shape)
p[np.triu_indices(p.shape[0], 1)] = pf
p[np.tril_indices(p.shape[0], -1)] = pf
p[np.diag_indices(p.shape[0])] = np.ones(p.shape[0])
return r, p
示例15: K
# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import betainc [as 别名]
def K(r, R, beta):
"""
equation A16 im Mamon & Lokas for constant anisotropy
:param r: 3d radius
:param R: projected 2d radius
:param beta: anisotropy
:return: K(r, R, beta)
"""
u = r / R
k = np.sqrt(1 - 1. / u ** 2) / (1. - 2 * beta) + np.sqrt(np.pi) / 2 * special.gamma(
beta - 1. / 2) / special.gamma(beta) \
* (3. / 2 - beta) * u ** (2 * beta - 1.) * (1 - special.betainc(beta + 1. / 2, 1. / 2, 1. / u ** 2))
return k