6 from PhysicsTools.HeppyCore.utils.diclist
import diclist
16 def add(self, value, weight=1.0):
18 Add a new sample to the average. 21 weight =
float(weight)
23 self.
sumwx += weight * value
24 self.
sumwx2 += weight * value * value
41 Uncertainty on the mean value 44 return math.sqrt( self.
variance() ) / math.sqrt( self.
sumw )
50 Returns: mean value, uncertainty on mean value. 55 '''Add two averages, merging the two samples.''' 56 self.
sumw += other.sumw
57 self.
sumwx += other.sumwx
58 self.
sumwx2 += other.sumwx2
62 '''Add two averages.''' 66 '''Dump the average to a pickle file and to a text file in dirname.''' 67 pckfname =
'{d}/{f}.pck'.
format(d=dirname, f=self.
name)
68 pckfile = open( pckfname,
'w' )
69 pickle.dump(self, pckfile)
70 txtfile = open( pckfname.replace(
'.pck',
'.txt'),
'w')
71 txtfile.write(
str(self) )
79 tmp =
'Average {name:<15}: {average: 8.4f} +- {unc:8.4f}' 81 tmp = tmp.format( name = self.
name,
86 tmp =
'Average {name:<15}: undefined (call Average.add)'\
94 map(
lambda x: x.write(dirname), self)
def __iadd__(self, other)
Abs< T >::type abs(const T &t)
def add(self, value, weight=1.0)