All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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__
 
def clear
 
def add
 
def n
 
def weights
 
def sum
 
def min
 
def max
 
def sumsq
 
def average
 
def sqaverage
 
def rms2
 
def rms
 
def stdev
 
def stdevp
 

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 
69  def __init__(self, bFloat = True):
70  self.clear(bFloat)

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

Definition at line 105 of file SortModuleTimes.py.

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

Definition at line 71 of file SortModuleTimes.py.

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

Definition at line 103 of file SortModuleTimes.py.

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

Definition at line 102 of file SortModuleTimes.py.

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.

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

Definition at line 111 of file SortModuleTimes.py.

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

Definition at line 108 of file SortModuleTimes.py.

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

Definition at line 113 of file SortModuleTimes.py.

114  def stdev(self):
115  if self.e_n < 2: return 0.
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.

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

Definition at line 101 of file SortModuleTimes.py.

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

Definition at line 104 of file SortModuleTimes.py.

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

Definition at line 100 of file SortModuleTimes.py.

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: