Public Member Functions | Public Attributes | List of all members
SortModuleTimes.Stats Class Reference
Inheritance diagram for SortModuleTimes.Stats:
SortModuleTimes.TimeModuleStatsClass

Public Member Functions

def __init__ (self, bFloat=True)
 
def clear (self, bFloat=True)
 
def add (self, value, weight=1)
 
def n (self)
 
def weights (self)
 
def sum (self)
 
def min (self)
 
def max (self)
 
def sumsq (self)
 
def average (self)
 
def sqaverage (self)
 
def rms2 (self)
 
def rms (self)
 
def stdev (self)
 
def stdevp (self)
 

Public Attributes

 e_n
 
 e_w
 
 e_sum
 
 e_sumsq
 
 e_min
 
 e_max
 

Detailed Description

Statistics collector.

This class accumulates statistics on a single variable.
A new entry is added by add(), that allowes an optional weight.
At any time, the following information about the sample of x is available:
- n():       number of additions
- weights(): total weight (matches n() unless weights are specified)
- sum():     weighted sum of x
- min():     minimum value of x seen so far (None if no entries yet)
- max():     maximum value of x seen so far (None if no entries yet)
- sumsq():   weighted sum of x^2
- average(): weighted average of x (0 if no entries yet)
- sqaverage(): weighted average of x^2 (0 if no entries yet)
- rms():     the Root Mean Square (including weights)
- rms2():    the square of the RMS (including weights)
- stdev():   standard deviation (0 if less than two events)
- stdevp():  an alias for rms()

The construction allows to specify bFloat = false, in which case the
accumulators are integral types (int) until a real type value or weight is
add()ed.

Definition at line 45 of file SortModuleTimes.py.

Constructor & Destructor Documentation

def SortModuleTimes.Stats.__init__ (   self,
  bFloat = True 
)
Statistics collector.

This class accumulates statistics on a single variable.
A new entry is added by add(), that allowes an optional weight.
At any time, the following information about the sample of x is available:
- n():       number of additions
- weights(): total weight (matches n() unless weights are specified)
- sum():     weighted sum of x
- min():     minimum value of x seen so far (None if no entries yet)
- max():     maximum value of x seen so far (None if no entries yet)
- sumsq():   weighted sum of x^2
- average(): weighted average of x (0 if no entries yet)
- sqaverage(): weighted average of x^2 (0 if no entries yet)
- rms():     the Root Mean Square (including weights)
- rms2():    the square of the RMS (including weights)
- stdev():   standard deviation (0 if less than two events)
- stdevp():  an alias for rms()

The construction allows to specify bFloat = false, in which case the
accumulators are integral types (int) until a real type value or weight is
add()ed.

Definition at line 68 of file SortModuleTimes.py.

68  def __init__(self, bFloat = True):
69  self.clear(bFloat)
70 
def __init__(self, bFloat=True)
def clear(self, bFloat=True)

Member Function Documentation

def SortModuleTimes.Stats.add (   self,
  value,
  weight = 1 
)
Add a new item.

The addition is treated as integer only if both value and weight are
integrals.

Definition at line 85 of file SortModuleTimes.py.

85  def add(self, value, weight=1):
86  """Add a new item.
87 
88  The addition is treated as integer only if both value and weight are
89  integrals.
90  """
91  self.e_n += 1
92  self.e_w += weight
93  self.e_sum += weight * value
94  self.e_sumsq += weight * value**2
95  if (self.e_min is None) or (value < self.e_min): self.e_min = value
96  if (self.e_max is None) or (value > self.e_max): self.e_max = value
def add(self, value, weight=1)
def SortModuleTimes.Stats.average (   self)

Definition at line 105 of file SortModuleTimes.py.

105  def average(self):
106  if self.e_w != 0.: return float(self.e_sum)/self.e_w
107  else: return 0.
def SortModuleTimes.Stats.clear (   self,
  bFloat = True 
)

Definition at line 71 of file SortModuleTimes.py.

71  def clear(self, bFloat = True):
72  self.e_n = 0
73  if bFloat:
74  self.e_w = 0.
75  self.e_sum = 0.
76  self.e_sumsq = 0.
77  else:
78  self.e_w = 0
79  self.e_sum = 0
80  self.e_sumsq = 0
81  self.e_min = None
82  self.e_max = None
def clear(self, bFloat=True)
def SortModuleTimes.Stats.max (   self)

Definition at line 103 of file SortModuleTimes.py.

103  def max(self): return self.e_max
def SortModuleTimes.Stats.min (   self)

Definition at line 102 of file SortModuleTimes.py.

102  def min(self): return self.e_min
def SortModuleTimes.Stats.n (   self)

Definition at line 99 of file SortModuleTimes.py.

99  def n(self): return self.e_n
def SortModuleTimes.Stats.rms (   self)

Definition at line 112 of file SortModuleTimes.py.

112  def rms(self): return signed_sqrt(self.rms2())
def SortModuleTimes.Stats.rms2 (   self)

Definition at line 111 of file SortModuleTimes.py.

111  def rms2(self): return self.sqaverage() - self.average()**2
def SortModuleTimes.Stats.sqaverage (   self)

Definition at line 108 of file SortModuleTimes.py.

108  def sqaverage(self):
109  if self.e_w != 0.: return float(self.e_sumsq)/self.e_w
110  else: return 0.
def SortModuleTimes.Stats.stdev (   self)

Definition at line 113 of file SortModuleTimes.py.

113  def stdev(self):
114  if self.e_n < 2: return 0.
115  else: return self.rms() * math.sqrt(float(self.e_n)/(self.e_n-1))
def SortModuleTimes.Stats.stdevp (   self)

Definition at line 116 of file SortModuleTimes.py.

116  def stdevp(self): return self.rms()
117 # class Stats
118 
119 
def SortModuleTimes.Stats.sum (   self)

Definition at line 101 of file SortModuleTimes.py.

101  def sum(self): return self.e_sum
def SortModuleTimes.Stats.sumsq (   self)

Definition at line 104 of file SortModuleTimes.py.

104  def sumsq(self): return self.e_sumsq
def SortModuleTimes.Stats.weights (   self)

Definition at line 100 of file SortModuleTimes.py.

100  def weights(self): return self.e_w

Member Data Documentation

SortModuleTimes.Stats.e_max

Definition at line 82 of file SortModuleTimes.py.

SortModuleTimes.Stats.e_min

Definition at line 81 of file SortModuleTimes.py.

SortModuleTimes.Stats.e_n

Definition at line 72 of file SortModuleTimes.py.

SortModuleTimes.Stats.e_sum

Definition at line 75 of file SortModuleTimes.py.

SortModuleTimes.Stats.e_sumsq

Definition at line 76 of file SortModuleTimes.py.

SortModuleTimes.Stats.e_w

Definition at line 74 of file SortModuleTimes.py.


The documentation for this class was generated from the following file: