OpenMPCD
Public Member Functions | Public Attributes | List of all members
MPCDAnalysis.OnTheFlyStatistics.OnTheFlyStatistics Class Reference

Public Member Functions

def __init__ (self, mean=None, sampleVariance=None, sampleSize=None)
 
def addDatum (self, datum)
 
def mergeSample (self, sample)
 
def mergeSamples (self, samples)
 
def getSampleSize (self)
 
def getSampleMean (self)
 
def getSampleVariance (self)
 
def getSampleStandardDeviation (self)
 
def getStandardErrorOfTheMean (self)
 
def serializeToString (self)
 
def unserializeFromString (self, state)
 
def __eq__ (self, rhs)
 
def __ne__ (self, rhs)
 
def __hash__ (self)
 
def __repr__ (self)
 

Public Attributes

 n
 
 M
 
 S
 

Detailed Description

Computes the sample mean and variance of provided data incrementally.

The algorithm used is described in the "updating formulas" (1.3) in the paper
"Algorithms for Computing the Sample Variance: Analysis and Recommendations"
by Tony F. Chan, Gene H. Golub, and Randall J. LeVeque,
The American Statistician, August 1983, Vol. 37, No. 3, pp. 242-247
DOI: 10.2307/2683386

See also "Formulas for Robust, One-Pass Parallel Computation of Covariances
and Arbitrary-Order Statistical Moments" by Philippe Pébay, Sandia Report
SAND2008-6212, 2008.

Definition at line 19 of file OnTheFlyStatistics.py.

Constructor & Destructor Documentation

◆ __init__()

def MPCDAnalysis.OnTheFlyStatistics.OnTheFlyStatistics.__init__ (   self,
  mean = None,
  sampleVariance = None,
  sampleSize = None 
)
    The constructor.

    The parameters `mean`, `sampleVariance`, and `sampleSize` can either be
    `None`, in which case an instance without any data points is
    constructed, or all three parameters can be specified, in which case
    the instance is constructed as if data were given that result in the
    specified parameters.

Definition at line 31 of file OnTheFlyStatistics.py.

Member Function Documentation

◆ __eq__()

def MPCDAnalysis.OnTheFlyStatistics.OnTheFlyStatistics.__eq__ (   self,
  rhs 
)
    The equality operator.

    Returns whether the state of this object is the same as the state of the
    `rhs` object; if `rhs` is not of this instance's type, `NotImplemented`
    is returned.

    @param[in] rhs The right-hand-side instance to compare to.

Definition at line 273 of file OnTheFlyStatistics.py.

◆ __hash__()

def MPCDAnalysis.OnTheFlyStatistics.OnTheFlyStatistics.__hash__ (   self)
    Returns a hash of this object that depends on its state, and nothing
    more.

Definition at line 304 of file OnTheFlyStatistics.py.

◆ __ne__()

def MPCDAnalysis.OnTheFlyStatistics.OnTheFlyStatistics.__ne__ (   self,
  rhs 
)
    The inequality operator.

    Returns whether the state of this object differs from the state of the
    `rhs` object; if `rhs` is not of this instance's type, `NotImplemented`
    is returned.

    @param[in] rhs The right-hand-side instance to compare to.

Definition at line 291 of file OnTheFlyStatistics.py.

◆ __repr__()

def MPCDAnalysis.OnTheFlyStatistics.OnTheFlyStatistics.__repr__ (   self)
    Returns a `str` describing the data of this instance.

Definition at line 313 of file OnTheFlyStatistics.py.

◆ addDatum()

def MPCDAnalysis.OnTheFlyStatistics.OnTheFlyStatistics.addDatum (   self,
  datum 
)
    Adds a datum to the sample.

Definition at line 59 of file OnTheFlyStatistics.py.

◆ getSampleMean()

def MPCDAnalysis.OnTheFlyStatistics.OnTheFlyStatistics.getSampleMean (   self)
    Returns the mean of all the values added so far.

    If no values have been added so far, an exception is thrown.

Definition at line 151 of file OnTheFlyStatistics.py.

◆ getSampleSize()

def MPCDAnalysis.OnTheFlyStatistics.OnTheFlyStatistics.getSampleSize (   self)
    Returns the number of data points added so far.

Definition at line 141 of file OnTheFlyStatistics.py.

◆ getSampleStandardDeviation()

def MPCDAnalysis.OnTheFlyStatistics.OnTheFlyStatistics.getSampleStandardDeviation (   self)
    Returns the unbiased sample standard deviation of all the values added
    so far.

    The returned value contains Bessel's correction, i.e. the sum of
    squares of differences is divided by \f$ n - 1 \f$ rather than
    \f$ n \f$, where \f$ n \f$ is the sample size.

    If fewer than two values have been added so far, an exception is thrown.

Definition at line 186 of file OnTheFlyStatistics.py.

◆ getSampleVariance()

def MPCDAnalysis.OnTheFlyStatistics.OnTheFlyStatistics.getSampleVariance (   self)
    Returns the unbiased sample variance of all the values added so far.

    The returned value contains Bessel's correction, i.e. the sum of
    squares of differences is divided by \f$ n - 1 \f$ rather than
    \f$ n \f$, where \f$ n \f$ is the sample size.

    If fewer than two values have been added so far, an exception is thrown.

Definition at line 168 of file OnTheFlyStatistics.py.

◆ getStandardErrorOfTheMean()

def MPCDAnalysis.OnTheFlyStatistics.OnTheFlyStatistics.getStandardErrorOfTheMean (   self)
    Returns the standard error of the mean, i.e. the unbiased sample
    standard deviation divided by the square root of the sample size.

Definition at line 196 of file OnTheFlyStatistics.py.

◆ mergeSample()

def MPCDAnalysis.OnTheFlyStatistics.OnTheFlyStatistics.mergeSample (   self,
  sample 
)
    Merges the given sample with this one.

    This assumes that both samples are drawn from the same population.

Definition at line 74 of file OnTheFlyStatistics.py.

◆ mergeSamples()

def MPCDAnalysis.OnTheFlyStatistics.OnTheFlyStatistics.mergeSamples (   self,
  samples 
)
    Merges the given samples with this one.

    This assumes that all samples are drawn from the same population.

Definition at line 131 of file OnTheFlyStatistics.py.

◆ serializeToString()

def MPCDAnalysis.OnTheFlyStatistics.OnTheFlyStatistics.serializeToString (   self)
    Returns a `str` that contains the state of this instance.

    @see unserializeFromString

Definition at line 208 of file OnTheFlyStatistics.py.

◆ unserializeFromString()

def MPCDAnalysis.OnTheFlyStatistics.OnTheFlyStatistics.unserializeFromString (   self,
  state 
)
    Discards the current state, and loads the state specified in the given
    string instead.

    @throw TypeError
           Throws if `state` is of the wrong type.
    @throw ValueError
           Throws if `state` does not encode a valid state.

    @param[in] state
               The state to load. Must be a `str` created by
               `serializeToString`.

Definition at line 234 of file OnTheFlyStatistics.py.


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