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


Python Util.powerLawProbs方法代码示例

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


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

示例1: simulateModel

# 需要导入模块: from sandbox.util.Util import Util [as 别名]
# 或者: from sandbox.util.Util.Util import powerLawProbs [as 别名]
    def simulateModel(theta):
        """
        The parameter t is the particle index. 
        """
        logging.debug("theta=" + str(theta))
 
        #We start with the observed graph at the start date 
        graph = targetGraph.subgraph(targetGraph.removedIndsAt(startDate)) 
        graph.addVertices(M-graph.size)

        p = Util.powerLawProbs(alpha, zeroVal)
        hiddenDegSeq = Util.randomChoice(p, graph.getNumVertices())
        
        featureInds = numpy.ones(graph.vlist.getNumFeatures(), numpy.bool)
        featureInds[HIVVertices.dobIndex] = False 
        featureInds[HIVVertices.infectionTimeIndex] = False 
        featureInds[HIVVertices.hiddenDegreeIndex] = False 
        featureInds[HIVVertices.stateIndex] = False
        featureInds = numpy.arange(featureInds.shape[0])[featureInds]
        matcher = GraphMatch(matchAlg, alpha=matchAlpha, featureInds=featureInds, useWeightM=False)
        graphMetrics = HIVGraphMetrics2(targetGraph, breakSize, matcher, float(endDate))
        
        recordStep = (endDate-startDate)/float(numRecordSteps)
        rates = HIVRates(graph, hiddenDegSeq)
        model = HIVEpidemicModel(graph, rates, T=float(endDate), T0=float(startDate), metrics=graphMetrics)
        model.setRecordStep(recordStep)
        model.setParams(theta)
        
        model.simulate() 
    
        objective = model.objective()
        return objective
开发者ID:charanpald,项目名称:wallhack,代码行数:34,代码来源:ModelRealExp2.py

示例2: testPowerLawProbs

# 需要导入模块: from sandbox.util.Util import Util [as 别名]
# 或者: from sandbox.util.Util.Util import powerLawProbs [as 别名]
    def testPowerLawProbs(self):
        alpha = 3
        zeroVal = 0.1
        maxInt = 100

        p = Util.powerLawProbs(alpha, zeroVal, maxInt)

        self.assertTrue(p.shape[0] == maxInt)
开发者ID:charanpald,项目名称:sandbox,代码行数:10,代码来源:UtilTest.py

示例3: setUp

# 需要导入模块: from sandbox.util.Util import Util [as 别名]
# 或者: from sandbox.util.Util.Util import powerLawProbs [as 别名]
    def setUp(self):
        numpy.seterr(invalid='raise')
        logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
        numpy.set_printoptions(suppress=True, precision=4, linewidth=100)
        numpy.random.seed(21)

        M = 1000
        undirected = True

        graph = HIVGraph(M, undirected)
        alpha = 2
        zeroVal = 0.9
        p = Util.powerLawProbs(alpha, zeroVal)
        hiddenDegSeq = Util.randomChoice(p, graph.getNumVertices())
        rates = HIVRates(graph, hiddenDegSeq)

        self.numParams = 6
        self.graph = graph
        self.meanTheta = numpy.array([100, 0.9, 0.05, 0.001, 0.1, 0.005])
        self.hivAbcParams = HIVABCParameters(self.meanTheta, self.meanTheta/2)
开发者ID:charanpald,项目名称:wallhack,代码行数:22,代码来源:HIVABCParametersTest.py


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