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


Python special.gammaincc方法代码示例

本文整理汇总了Python中scipy.special.gammaincc方法的典型用法代码示例。如果您正苦于以下问题:Python special.gammaincc方法的具体用法?Python special.gammaincc怎么用?Python special.gammaincc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy.special的用法示例。


在下文中一共展示了special.gammaincc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: longestrunones8

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import gammaincc [as 别名]
def longestrunones8(binin):
    ''' The focus of the test is the longest run of ones within M-bit blocks. The purpose of this test is to determine whether the length of the longest run of ones within the tested sequence is consistent with the length of the longest run of ones that would be expected in a random sequence. Note that an irregularity in the expected length of the longest run of ones implies that there is also an irregularity in the expected length of the longest run of zeroes. Long runs of zeroes were not evaluated separately due to a concern about statistical independence among the tests.'''
    m = 8
    k = 3
    pik = [0.2148, 0.3672, 0.2305, 0.1875]
    blocks = [binin[xs*m:m+xs*m:] for xs in range(len(binin) / m)]
    n = len(blocks)
    # append the string 01 to guarantee the length of 1
    counts1 = [xs+'01' for xs in blocks]
    counts = [xs.replace('0', ' ').split()
              for xs in counts1]  # split into all parts
    counts2 = [list(map(len, xx)) for xx in counts]
    counts4 = [(4 if xx > 4 else xx) for xx in map(max, counts2)]
    freqs = [counts4.count(spi) for spi in [1, 2, 3, 4]]
    chisqr1 = [(freqs[xx]-n*pik[xx])**2/(n*pik[xx]) for xx in range(4)]
    chisqr = reduce(su, chisqr1)
    pval = spc.gammaincc(k / 2.0, chisqr / 2.0)
    return pval 
开发者ID:s0md3v,项目名称:Bolt,代码行数:20,代码来源:entropy.py

示例2: longestrunones128

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import gammaincc [as 别名]
def longestrunones128(binin):  # not well tested yet
    if len(binin) > 128:
        m = 128
        k = 5
        n = len(binin)
        pik = [0.1174, 0.2430, 0.2493, 0.1752, 0.1027, 0.1124]
        blocks = [binin[xs * m:m + xs * m:] for xs in range(len(binin) / m)]
        n = len(blocks)
        counts = [xs.replace('0', ' ').split() for xs in blocks]
        counts2 = [list(map(len, xx)) for xx in counts]
        counts3 = [(1 if xx < 1 else xx) for xx in map(max, counts2)]
        counts4 = [(4 if xx > 4 else xx) for xx in counts3]
        chisqr1 = [(counts4[xx] - n * pik[xx]) ** 2 / (n * pik[xx])
                   for xx in range(len(counts4))]
        chisqr = reduce(su, chisqr1)
        pval = spc.gammaincc(k / 2.0, chisqr / 2.0)
    else:
        print('longestrunones128 failed, too few bits:', len(binin))
        pval = 0
    return pval 
开发者ID:s0md3v,项目名称:Bolt,代码行数:22,代码来源:entropy.py

示例3: longestrunones10000

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import gammaincc [as 别名]
def longestrunones10000(binin):  # not well tested yet
    ''' The focus of the test is the longest run of ones within M-bit blocks. The purpose of this test is to determine whether the length of the longest run of ones within the tested sequence is consistent with the length of the longest run of ones that would be expected in a random sequence. Note that an irregularity in the expected length of the longest run of ones implies that there is also an irregularity in the expected length of the longest run of zeroes. Long runs of zeroes were not evaluated separately due to a concern about statistical independence among the tests.'''
    if len(binin) > 128:
        m = 10000
        k = 6
        pik = [0.0882, 0.2092, 0.2483, 0.1933, 0.1208, 0.0675, 0.0727]
        blocks = [binin[xs * m:m + xs * m:]
                  for xs in range(floor(len(binin) / m))]
        n = len(blocks)
        counts = [xs.replace('0', ' ').split() for xs in blocks]
        counts2 = [list(map(len, xx)) for xx in counts]
        counts3 = [(10 if xx < 10 else xx) for xx in map(max, counts2)]
        counts4 = [(16 if xx > 16 else xx) for xx in counts3]
        freqs = [counts4.count(spi) for spi in [10, 11, 12, 13, 14, 15, 16]]
        chisqr1 = [(freqs[xx] - n * pik[xx]) ** 2 / (n * pik[xx])
                   for xx in range(len(freqs))]
        chisqr = reduce(su, chisqr1)
        pval = spc.gammaincc(k / 2.0, chisqr / 2.0)
    else:
        print('longestrunones10000 failed, too few bits:', len(binin))
        pval = 0
    return pval

# test 2.06 
开发者ID:s0md3v,项目名称:Bolt,代码行数:26,代码来源:entropy.py

示例4: randomexcursionstest

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import gammaincc [as 别名]
def randomexcursionstest(binin):
    ''' The focus of this test is the number of cycles having exactly K visits in a cumulative sum random walk. The cumulative sum random walk is found if partial sums of the (0,1) sequence are adjusted to (-1, +1). A random excursion of a random walk consists of a sequence of n steps of unit length taken at random that begin at and return to the origin. The purpose of this test is to determine if the number of visits to a state within a random walk exceeds what one would expect for a random sequence.'''
    xvals = [-4, -3, -2, -1, 1, 2, 3, 4]
    ss = [int(el) for el in binin]
    sc = list(map(sumi, ss))
    cumsum = np.cumsum(sc)
    cumsum = np.append(cumsum, 0)
    cumsum = np.append(0, cumsum)
    posi = np.where(cumsum == 0)[0]
    cycles = ([cumsum[posi[x]:posi[x+1]+1] for x in range(len(posi)-1)])
    j = len(cycles)
    sct = []
    for ii in cycles:
        sct.append(([len(np.where(ii == xx)[0]) for xx in xvals]))
    sct = np.transpose(np.clip(sct, 0, 5))
    su = []
    for ii in range(6):
        su.append([(xx == ii).sum() for xx in sct])
    su = np.transpose(su)
    pikt = ([([pik(uu, xx) for uu in range(6)]) for xx in xvals])
    # chitab=1.0*((su-j*pikt)**2)/(j*pikt)
    chitab = np.sum(1.0*(np.array(su)-j*np.array(pikt))
                    ** 2/(j*np.array(pikt)), axis=1)
    pval = ([spc.gammaincc(2.5, cs/2.0) for cs in chitab])
    return pval 
开发者ID:s0md3v,项目名称:Bolt,代码行数:27,代码来源:entropy.py

示例5: inc_gamma

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import gammaincc [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) 
开发者ID:GeoStat-Framework,项目名称:GSTools,代码行数:21,代码来源:special.py

示例6: _sf

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import gammaincc [as 别名]
def _sf(self, x, a):
        return sc.gammaincc(a, x) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:4,代码来源:_continuous_distns.py

示例7: _cdf

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import gammaincc [as 别名]
def _cdf(self, x, a, c):
        xc = x**c
        val1 = sc.gammainc(a, xc)
        val2 = sc.gammaincc(a, xc)
        return np.where(c > 0, val1, val2) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:7,代码来源:_continuous_distns.py

示例8: complete_gamma

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import gammaincc [as 别名]
def complete_gamma(a, z):
    """
    return 'complete' gamma function
    """
    return exp1(z) if a == 0 else gamma(a)*gammaincc(a, z) 
开发者ID:ocelot-collab,项目名称:ocelot,代码行数:7,代码来源:math_op.py

示例9: test_gammaincc

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import gammaincc [as 别名]
def test_gammaincc(self):
        assert_equal(cephes.gammaincc(5,0),1.0) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:4,代码来源:test_basic.py

示例10: test_gammainccnan

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import gammaincc [as 别名]
def test_gammainccnan(self):
        gama = special.gammaincc(-1,1)
        assert_(isnan(gama)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:5,代码来源:test_basic.py

示例11: test_pdtrik

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import gammaincc [as 别名]
def test_pdtrik(self):
        k = cephes.pdtrik(0.5, 1)
        assert_almost_equal(cephes.gammaincc(k + 1, 1), 0.5)
        # Edge case: m = 0 or very small.
        k = cephes.pdtrik([[0], [0.25], [0.95]], [0, 1e-20, 1e-6])
        assert_array_equal(k, np.zeros((3, 3))) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:8,代码来源:test_basic.py

示例12: test_gammainccinf

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import gammaincc [as 别名]
def test_gammainccinf(self):
        gama = special.gammaincc(0.5,np.inf)
        assert_equal(gama,0.0) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:5,代码来源:test_basic.py

示例13: test_gammaincc

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import gammaincc [as 别名]
def test_gammaincc(self):
        # Larger arguments are tested in test_data.py:test_local
        assert_mpmath_equal(sc.gammaincc,
                            lambda z, a: mpmath.gammainc(z, a=a, regularized=True),
                            [Arg(0, 1e4, inclusive_a=False), Arg(0, 1e4)],
                            nan_ok=False, rtol=1e-11) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:8,代码来源:test_mpmath.py

示例14: blockfrequencytest

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import gammaincc [as 别名]
def blockfrequencytest(binin, nu=20):
    ''' The focus of the test is the proportion of zeroes and ones within M-bit blocks. The purpose of this test is to determine whether the frequency of ones is an M-bit block is approximately M/2.'''
    ss = [int(el) for el in binin]
    tt = [1.0 * sum(ss[xs * nu:nu + xs * nu:]) /
          nu for xs in range(floor(len(ss) / nu))]
    uu = list(map(sus, tt))
    chisqr = 4 * nu * reduce(su, uu, 0)
    pval = spc.gammaincc(len(tt) / 2.0, chisqr / 2.0)
    return pval 
开发者ID:s0md3v,项目名称:Bolt,代码行数:11,代码来源:entropy.py

示例15: nonoverlappingtemplatematchingtest

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import gammaincc [as 别名]
def nonoverlappingtemplatematchingtest(binin, mat="000000001", num=9):
    ''' The focus of this test is the number of occurrences of pre-defined target substrings. The purpose of this test is to reject sequences that exhibit too many occurrences of a given non-periodic (aperiodic) pattern. For this test and for the Overlapping Template Matching test, an m-bit window is used to search for a specific m-bit pattern. If the pattern is not found, the window slides one bit position. For this test, when the pattern is found, the window is reset to the bit after the found pattern, and the search resumes.'''
    n = len(binin)
    m = len(mat)
    M = floor(n/num)
    blocks = [binin[xs*M:M+xs*M:] for xs in range(floor(n/M))]
    counts = [xx.count(mat) for xx in blocks]
    avg = 1.0 * (M-m+1)/2 ** m
    var = M*(2**-m - (2*m-1)*2**(-2*m))
    chisqr = reduce(su, [(xs - avg) ** 2 for xs in counts]) / var
    pval = spc.gammaincc(1.0 * len(blocks) / 2, chisqr / 2)
    return pval 
开发者ID:s0md3v,项目名称:Bolt,代码行数:14,代码来源:entropy.py


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