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


Python scipy.sum方法代码示例

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


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

示例1: coupling_optim_garrick

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import sum [as 别名]
def coupling_optim_garrick(y,t):
	creation=s.zeros(n_bin)
	destruction=s.zeros(n_bin)
	#now I try to rewrite this in a more optimized way
	destruction = -s.dot(s.transpose(kernel),y)*y #much more concise way to express\
	#the destruction of k-mers 
	
	for k in xrange(n_bin):
		kyn = (kernel*f_garrick[:,:,k])*y[:,s.newaxis]*y[s.newaxis,:]
		creation[k] = s.sum(kyn)
	creation=0.5*creation
	out=creation+destruction
	return out



#Now I work with the function for espressing smoluchowski equation when a uniform grid is used 
开发者ID:ActiveState,项目名称:code,代码行数:19,代码来源:recipe-576547.py

示例2: coupling_optim

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import sum [as 别名]
def coupling_optim(y,t):
	creation=s.zeros(n_bin)
	destruction=s.zeros(n_bin)
	#now I try to rewrite this in a more optimized way
	destruction = -s.dot(s.transpose(kernel),y)*y #much more concise way to express\
	#the destruction of k-mers 
	kyn = kernel*y[:,s.newaxis]*y[s.newaxis,:]
	for k in xrange(n_bin):
		creation[k] = s.sum(kyn[s.arange(k),k-s.arange(k)-1])
	creation=0.5*creation
	out=creation+destruction
	return out


#Now I go for the optimal optimization of the chi_{i,j,k} coefficients used by Garrick for
# dealing with a non-uniform grid. 
开发者ID:ActiveState,项目名称:code,代码行数:18,代码来源:recipe-576547.py

示例3: __MR_W_D_matrix

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import sum [as 别名]
def __MR_W_D_matrix(self,img,labels):
        s = sp.amax(labels)+1
        vect = self.__MR_superpixel_mean_vector(img,labels)
        
        adj = self.__MR_get_adj_loop(labels)
        
        W = sp.spatial.distance.squareform(sp.spatial.distance.pdist(vect))
        
        W = sp.exp(-1*W / self.weight_parameters['delta'])
        W[adj.astype(np.bool)] = 0
        

        D = sp.zeros((s,s)).astype(float)
        for i in range(s):
            D[i, i] = sp.sum(W[i])

        return W,D 
开发者ID:ruanxiang,项目名称:mr_saliency,代码行数:19,代码来源:MR.py

示例4: CalculateWeiner

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import sum [as 别名]
def CalculateWeiner(mol):
    """
    #################################################################
    Calculation of Weiner number in a molecule

    ---->W

    Usage:

        result=CalculateWeiner(mol)

        Input: mol is a molecule object

        Output: result is a numeric value
    #################################################################
    """
    return 1.0 / 2 * sum(sum(Chem.GetDistanceMatrix(mol))) 
开发者ID:gadsbyfly,项目名称:PyBioMed,代码行数:19,代码来源:topology.py

示例5: CalculatePolarityNumber

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import sum [as 别名]
def CalculatePolarityNumber(mol):
    """
    #################################################################
    Calculation of Polarity number.

    It is the number of pairs of vertexes at

    distance matrix equal to 3

    ---->Pol

    Usage:

        result=CalculatePolarityNumber(mol)

        Input: mol is a molecule object

        Output: result is a numeric value
    #################################################################
    """
    Distance = Chem.GetDistanceMatrix(mol)
    res = 1.0 / 2 * sum(sum(Distance == 3))

    return res 
开发者ID:gadsbyfly,项目名称:PyBioMed,代码行数:26,代码来源:topology.py

示例6: CalculateHarary

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import sum [as 别名]
def CalculateHarary(mol):
    """
    #################################################################
    Calculation of Harary number

    ---->Thara

    Usage:

        result=CalculateHarary(mol)

        Input: mol is a molecule object

        Output: result is a numeric value
    #################################################################
    """

    Distance = numpy.array(Chem.GetDistanceMatrix(mol), "d")

    return 1.0 / 2 * (sum(1.0 / Distance[Distance != 0])) 
开发者ID:gadsbyfly,项目名称:PyBioMed,代码行数:22,代码来源:topology.py

示例7: CalculateSchiultz

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import sum [as 别名]
def CalculateSchiultz(mol):
    """
    #################################################################
    Calculation of Schiultz number

    ---->Tsch(log value)

    Usage:

        result=CalculateSchiultz(mol)

        Input: mol is a molecule object

        Output: result is a numeric value
    #################################################################
    """
    Distance = numpy.array(Chem.GetDistanceMatrix(mol), "d")
    Adjacent = numpy.array(Chem.GetAdjacencyMatrix(mol), "d")
    VertexDegree = sum(Adjacent)

    return sum(scipy.dot((Distance + Adjacent), VertexDegree)) 
开发者ID:gadsbyfly,项目名称:PyBioMed,代码行数:23,代码来源:topology.py

示例8: CalculateZagreb1

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import sum [as 别名]
def CalculateZagreb1(mol):
    """
    #################################################################
    Calculation of Zagreb index with order 1 in a molecule

    ---->ZM1

    Usage:

        result=CalculateZagreb1(mol)

        Input: mol is a molecule object

        Output: result is a numeric value
    #################################################################
    """

    deltas = [x.GetDegree() for x in mol.GetAtoms()]
    return sum(numpy.array(deltas) ** 2) 
开发者ID:gadsbyfly,项目名称:PyBioMed,代码行数:21,代码来源:topology.py

示例9: CalculateZagreb2

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import sum [as 别名]
def CalculateZagreb2(mol):

    """
    #################################################################
    Calculation of Zagreb index with order 2 in a molecule

    ---->ZM2

    Usage:

        result=CalculateZagreb2(mol)

        Input: mol is a molecule object

        Output: result is a numeric value
    #################################################################
    """
    ke = [
        x.GetBeginAtom().GetDegree() * x.GetEndAtom().GetDegree()
        for x in mol.GetBonds()
    ]

    return sum(ke) 
开发者ID:gadsbyfly,项目名称:PyBioMed,代码行数:25,代码来源:topology.py

示例10: CalculateMZagreb2

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import sum [as 别名]
def CalculateMZagreb2(mol):
    """
    #################################################################
    Calculation of Modified Zagreb index with order 2 in a molecule

    ---->MZM2

    Usage:

        result=CalculateMZagreb2(mol)

        Input: mol is a molecule object

        Output: result is a numeric value
    #################################################################
    """
    cc = [
        x.GetBeginAtom().GetDegree() * x.GetEndAtom().GetDegree()
        for x in mol.GetBonds()
    ]
    while 0 in cc:
        cc.remove(0)
    cc = numpy.array(cc, "d")
    res = sum((1.0 / cc) ** 2)
    return res 
开发者ID:gadsbyfly,项目名称:PyBioMed,代码行数:27,代码来源:topology.py

示例11: CalculatePlatt

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import sum [as 别名]
def CalculatePlatt(mol):
    """
    #################################################################
    Calculation of Platt number in a molecule

    ---->Platt

    Usage:

        result=CalculatePlatt(mol)

        Input: mol is a molecule object

        Output: result is a numeric value
    #################################################################
    """
    cc = [
        x.GetBeginAtom().GetDegree() + x.GetEndAtom().GetDegree() - 2
        for x in mol.GetBonds()
    ]
    return sum(cc) 
开发者ID:gadsbyfly,项目名称:PyBioMed,代码行数:23,代码来源:topology.py

示例12: CalculateHarmonicTopoIndex

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import sum [as 别名]
def CalculateHarmonicTopoIndex(mol):
    """
    #################################################################
    Calculation of harmonic topological index proposed by Narnumi.

    ---->Hato

    Usage:

        result=CalculateHarmonicTopoIndex(mol)

        Input: mol is a molecule object

        Output: result is a numeric value
    #################################################################
    """
    deltas = [x.GetDegree() for x in mol.GetAtoms()]
    while 0 in deltas:
        deltas.remove(0)
    deltas = numpy.array(deltas, "d")
    nAtoms = mol.GetNumAtoms()

    res = nAtoms / sum(1.0 / deltas)

    return res 
开发者ID:gadsbyfly,项目名称:PyBioMed,代码行数:27,代码来源:topology.py

示例13: compare_images

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import sum [as 别名]
def compare_images(img1, img2, method='zeronorm'):
    # normalize to compensate for exposure difference, this may be unnecessary
    # consider disabling it
    img1 = normalize(img1)
    img2 = normalize(img2)
    # calculate the difference and its norms
    diff = img1 - img2  # elementwise for scipy arrays
    if method in 'zeronorm':
        inorm = norm(diff.ravel(), 0)  # Zero norm
    else:
        inorm = sum(abs(diff))  # Manhattan norm
    #normalise by image size
    inorm /= float(img1.size)
    return inorm


################################################################################# 
开发者ID:NelisW,项目名称:pyradi,代码行数:19,代码来源:_docopyregression.py

示例14: error

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import sum [as 别名]
def error(f, x, y):
    return sp.sum((f(x) - y) ** 2) 
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:4,代码来源:analyze_webstats.py

示例15: __minowski_low_positive_integer_p

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import sum [as 别名]
def __minowski_low_positive_integer_p(h1, h2, p = 2): # 11..43 us for p = 1..24 \w 100 bins
    """
    A faster implementation of the Minowski distance for positive integer < 25.
    @note do not use this function directly, but the general @link minowski() method.
    @note the passed histograms must be scipy arrays.
    """
    mult = scipy.absolute(h1 - h2)
    dif = mult
    for _ in range(p - 1): dif = scipy.multiply(dif, mult)
    return math.pow(scipy.sum(dif), 1./p) 
开发者ID:doublechenching,项目名称:brats_segmentation-pytorch,代码行数:12,代码来源:histogram.py


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