当前位置: 首页>>代码示例>>Python>>正文


Python special.betainc方法代码示例

本文整理汇总了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) 
开发者ID:NCAR,项目名称:esmlab,代码行数:26,代码来源:statistics.py

示例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 
开发者ID:XENON1T,项目名称:pax,代码行数:18,代码来源:S1AreaFractionTopProbability.py

示例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       #
##################################### 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:11,代码来源:stats.py

示例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) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:6,代码来源:mstats_basic.py

示例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) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:5,代码来源:_discrete_distns.py

示例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  #######
##################################### 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:35,代码来源:stats.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:6,代码来源:mstats_basic.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:4,代码来源:test_basic.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:6,代码来源:test_basic.py

示例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) 
开发者ID:deeptools,项目名称:HiCExplorer,代码行数:9,代码来源:viewpoint.py

示例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)) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:16,代码来源:test_continuous_basic.py

示例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) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:5,代码来源:test_basic.py

示例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) 
开发者ID:GeoStat-Framework,项目名称:GSTools,代码行数:17,代码来源:special.py

示例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 
开发者ID:wiheto,项目名称:teneto,代码行数:15,代码来源:corrcoef_matrix.py

示例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 
开发者ID:sibirrer,项目名称:lenstronomy,代码行数:16,代码来源:anisotropy.py


注:本文中的scipy.special.betainc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。