/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Public Attributes
DybAlg::TestRandom::RandomEater Class Reference

List of all members.

Public Member Functions

def __init__
def clear
def check
def __call__

Public Attributes

 ran
 nrans
 count
 numbers
 avg
 rms
 nevents

Detailed Description

Definition at line 29 of file TestRandom.py.


Constructor & Destructor Documentation

def DybAlg::TestRandom::RandomEater::__init__ (   self,
  nrans,
  ran 
)

Definition at line 30 of file TestRandom.py.

00031                                 :
00032         self.ran = ran
00033         self.nrans = nrans
00034         self.count = 0
00035         self.numbers = [0]*nrans
00036         self.avg = [0]*nrans
00037         self.rms = [0]*nrans
00038         self.nevents = 0


Member Function Documentation

def DybAlg::TestRandom::RandomEater::clear (   self)

Definition at line 39 of file TestRandom.py.

00040                    :
00041         if self.nrans != self.count:
00042             raise RuntimeError, "RandomEater not called enough %d != %d" %\
00043                 (self.ntrans,self.count)
00044 
00045         self.avg = map(lambda x: x[0]+x[1], zip(self.avg,self.numbers))
00046         self.rms = map(lambda x: x[0]+x[1]*x[1], zip(self.rms,self.numbers))
00047         self.numbers = [0]*self.nrans
00048         self.count = 0
00049         self.nevents += 1
00050         return

def DybAlg::TestRandom::RandomEater::check (   self)

Definition at line 51 of file TestRandom.py.

00052                    :
00053         import math
00054         avg = map(lambda x: x/self.nevents, self.avg)
00055         rms = map(lambda x: math.sqrt((x[1] - self.nevents*x[0]**2)/(self.nevents-1)),
00056                   zip(avg,self.rms))
00057 
00058         nbad = 0
00059         count = 0;
00060         target_mean = self.ran.max/2.0
00061         target_width = self.ran.max/math.sqrt(12)
00062         target_mean_eps = 200*target_width/self.nevents
00063         target_width_eps = 0.1*target_width
00064 
00065         for mean, width in zip(avg,rms):
00066             #print '%s random at %d: %f +/- %f' % (self.ran.name,count,mean,width)
00067             if abs(mean-target_mean) > target_mean_eps or \
00068                     abs(width-target_width) > target_width_eps:
00069                 print 'Rogue %s random at %d: %f(%f,%f) +/- %f(%f,%f)' % \
00070                     (self.ran.name,count,
00071                      mean,mean-target_mean,(mean-target_mean)/target_mean_eps,
00072                      width,width-target_width,(width-target_width)/target_width_eps)
00073                 nbad += 1
00074             count += 1
00075             continue
00076         return nbad
00077 

def DybAlg::TestRandom::RandomEater::__call__ (   self)

Definition at line 78 of file TestRandom.py.

00079                       :
00080         if self.count > self.nrans:
00081             raise RuntimeError, 'RandomEater called more than max %d'%self.nrans
00082         num = self.ran()
00083         self.numbers[self.count] = num
00084         self.count += 1
        return num

Member Data Documentation

Definition at line 30 of file TestRandom.py.

Definition at line 30 of file TestRandom.py.

Definition at line 30 of file TestRandom.py.

Definition at line 30 of file TestRandom.py.

Definition at line 30 of file TestRandom.py.

Definition at line 30 of file TestRandom.py.

Definition at line 30 of file TestRandom.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:09:44 for DybAlg by doxygen 1.7.4