def testGlobalShotNoise(self): for sn, sng in ((5, self.constant5Burstgen), (50, self.constant50Burstgen), (500, self.constant500Burstgen), (5000, self.constant5000Burstgen)): tm = GlobalAVGKappaTransferMatrix(20, 11, 1000, sng, 5.475, (5, 6)) tmx = tm.getMatrix() print "Burstsizes %d" % sn for _ in range(7): mbin = random.choice(range(20)) binmid = generateBinMid(1, mbin, 20, 5) eff = rToEff(binmid, R0 = 5.475) print "Testing mbin %d at pos %f with efficiency %f" % (mbin, binmid, eff) shotnoise = getShotNoise(eff, 11, 1000, sn) tmxvec = tmx[mbin, :] tmxvec.shape = (11, 1) self.assertAlmostEqual((tmxvec - shotnoise).sum(), 0.0, delta = 0.005)
def testDistanceAVGShotNoise(self): R = numpy.linspace(5, 6, 1100) kappa = [ 2. / 3 ] * 1100 weights = [ 1. ] * 1100 for sn, sng in ((5, self.constant5Burstgen), (50, self.constant50Burstgen), (500, self.constant500Burstgen), (5000, self.constant5000Burstgen)): tm = DistanceAVGKappaTransferMatrix(20, 11, 1000, sng, 5.475, R, kappa, weights, RRange = (5, 6)) tmx = tm.getMatrix() print "Burstsizes %d" % sn for _ in range(7): mbin = random.choice(range(20)) binmid = generateBinMid(1, mbin, 20, 5) eff = rToEff(binmid, R0 = 5.475) print "Testing mbin %d at pos %f with efficiency %f" % (mbin, binmid, eff) shotnoise = getShotNoise(eff, 11, 1000, sn) tmxvec = tmx[mbin, :] tmxvec.shape = (11, 1) self.assertAlmostEqual((tmxvec - shotnoise).sum(), 0.0, delta = 0.005)