def getBinEfficiencies(self, binnr): binmid = generateBinMid(self.myrange, binnr, self.RBins, self.RRange[0]) myR0 = self.getR0(binnr) reff = rToEff(binmid, myR0) print "Bin efficiency is %6.4f" % reff return [reff] * self.BurstCount, getBurstSizes(self.BurstCount, self.burstGenerator)
def calculateBursts(traj, eprob, conf, nbursts, randseed): """calculates efficiencies from trajectories with given probabilities and given configuration, here the burst sizes are determined""" pyrand.seed(randseed) nprand.seed(pyrand.randint(0, sys.maxint)) verbose = conf.get("System", "verbose") burstGenerator = getBurstSizeGenerator(conf, verbose) if verbose: print "Calculating bursts sizes." burstsizelist = getBurstSizes(nbursts, burstGenerator) return getBursts(traj, eprob, conf, burstsizelist)
def getDistanceBursts(trajectories, probabilities, config): print "Generating Bursts" burstGenerator = getBurstSizeGenerator(config, 1) nbursts = config.get("Burst Size Distribution", "nbursts") burstsizelist = getBurstSizes(nbursts, burstGenerator) burstdists = [] for bs in burstsizelist: burstdists.append(generateBurst(trajectories, probabilities, config, bs)) if (len(burstdists) % 100 == 0): print "\r %d of %d completed." % (len(burstdists), len(burstsizelist)), return numpy.array(burstdists)
def getDistanceBursts(trajectories, probabilities, config): print "Generating Bursts" burstGenerator = getBurstSizeGenerator(config, 1) nbursts = config.get("Burst Size Distribution", "nbursts") burstsizelist = getBurstSizes(nbursts, burstGenerator) burstdists = [] for bs in burstsizelist: burstdists.append( generateBurst(trajectories, probabilities, config, bs)) if (len(burstdists) % 100 == 0): print "\r %d of %d completed." % (len(burstdists), len(burstsizelist)), return numpy.array(burstdists)
def getBinEfficiencies(self, binnr): if not self.kappaBinned: self.binKappa() bursts = getBurstSizes(self.BurstCount, self.burstGenerator) beffs = [] rkprb = np.array(self.rkappaBinned[binnr]) Rarr = rkprb[:, 0] Kappaarr = rkprb[:, 1] Prbarr = rkprb[:, 2]**0 # R0s_mod = modifyR0(self.R0, Kappaarr) # # cumulprb = Prbarr.cumsum() # cumulprb /= cumulprb[-1] # for burst in bursts: # randnrs = np.random.random(burst) # ndxchoice = cumulprb.searchsorted(randnrs) # effs = rToEff(Rarr[ndxchoice], R0s_mod[ndxchoice]) # beffs.append(effs) cumulprb = Prbarr.cumsum() cumulprb /= cumulprb[-1] for burst in bursts: randnrs = np.random.random(burst) ndxchoice = cumulprb.searchsorted(randnrs) Ravg = Rarr[ndxchoice].mean() Kavg = Kappaarr[ndxchoice].mean() R0_mod = modifyR0(self.R0, Kavg) effs = rToEff(Ravg, R0_mod) beffs.append(effs) print "%d Efficiencies for bursts in bin %d calculated from %d R-K samples" % ( len(beffs), binnr, R0_mod) return beffs, bursts
def getBinEfficiencies(self, binnr): if not self.kappaBinned: self.binKappa() bursts = getBurstSizes(self.BurstCount, self.burstGenerator) beffs = [] rkprb = np.array(self.rkappaBinned[binnr]) Rarr = rkprb[:, 0] Kappaarr = rkprb[:, 1] Prbarr = rkprb[:, 2] ** 0 # R0s_mod = modifyR0(self.R0, Kappaarr) # # cumulprb = Prbarr.cumsum() # cumulprb /= cumulprb[-1] # for burst in bursts: # randnrs = np.random.random(burst) # ndxchoice = cumulprb.searchsorted(randnrs) # effs = rToEff(Rarr[ndxchoice], R0s_mod[ndxchoice]) # beffs.append(effs) cumulprb = Prbarr.cumsum() cumulprb /= cumulprb[-1] for burst in bursts: randnrs = np.random.random(burst) ndxchoice = cumulprb.searchsorted(randnrs) Ravg = Rarr[ndxchoice].mean() Kavg = Kappaarr[ndxchoice].mean() R0_mod = modifyR0(self.R0, Kavg) effs = rToEff(Ravg, R0_mod) beffs.append(effs) print "%d Efficiencies for bursts in bin %d calculated from %d R-K samples" % (len(beffs), binnr, R0_mod) return beffs, bursts