本文整理汇总了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
示例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)
示例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)