Public Member Functions | |
def | __init__ |
def | clear |
def | check |
def | __call__ |
Public Attributes | |
ran | |
nrans | |
count | |
numbers | |
avg | |
rms | |
nevents |
Definition at line 29 of file TestRandom.py.
def DybAlg::TestRandom::RandomEater::__init__ | ( | self, | ||
nrans, | ||||
ran | ||||
) |
def DybAlg::TestRandom::RandomEater::clear | ( | self | ) |
Definition at line 39 of file TestRandom.py.
00039 : 00040 if self.nrans != self.count: 00041 raise RuntimeError, "RandomEater not called enough %d != %d" %\ 00042 (self.ntrans,self.count) 00043 00044 self.avg = map(lambda x: x[0]+x[1], zip(self.avg,self.numbers)) 00045 self.rms = map(lambda x: x[0]+x[1]*x[1], zip(self.rms,self.numbers)) 00046 self.numbers = [0]*self.nrans 00047 self.count = 0 00048 self.nevents += 1 00049 return 00050 def check(self):
def DybAlg::TestRandom::RandomEater::check | ( | self | ) |
Definition at line 51 of file TestRandom.py.
00051 : 00052 import math 00053 avg = map(lambda x: x/self.nevents, self.avg) 00054 rms = map(lambda x: math.sqrt((x[1] - self.nevents*x[0]**2)/(self.nevents-1)), 00055 zip(avg,self.rms)) 00056 00057 nbad = 0 00058 count = 0; 00059 target_mean = self.ran.max/2.0 00060 target_width = self.ran.max/math.sqrt(12) 00061 target_mean_eps = 100*target_width/self.nevents 00062 target_width_eps = 0.1*target_width 00063 00064 for mean, width in zip(avg,rms): 00065 #print '%s random at %d: %f +/- %f' % (self.ran.name,count,mean,width) 00066 if abs(mean-target_mean) > target_mean_eps or \ 00067 abs(width-target_width) > target_width_eps: 00068 print 'Rogue %s random at %d: %f(%f,%f) +/- %f(%f,%f)' % \ 00069 (self.ran.name,count, 00070 mean,mean-target_mean,(mean-target_mean)/target_mean_eps, 00071 width,width-target_width,(width-target_width)/target_width_eps) 00072 nbad += 1 00073 count += 1 00074 continue 00075 return nbad 00076 00077 def __call__(self):
def DybAlg::TestRandom::RandomEater::__call__ | ( | self | ) |
Definition at line 31 of file TestRandom.py.
Definition at line 32 of file TestRandom.py.
Definition at line 33 of file TestRandom.py.
Definition at line 34 of file TestRandom.py.
Definition at line 35 of file TestRandom.py.
Definition at line 36 of file TestRandom.py.
Definition at line 37 of file TestRandom.py.