OpenMPCD
Public Member Functions | List of all members
OpenMPCD::OnTheFlyStatisticsDDDA< T > Class Template Reference

Computes sample means and their errors for (possibly) serially correlated data. More...

#include <OnTheFlyStatisticsDDDA.hpp>

Public Member Functions

 OnTheFlyStatisticsDDDA ()
 The constructor. More...
 
void addDatum (const T &datum)
 Adds a datum to the sample. More...
 
std::size_t getSampleSize () const
 Returns the number of data points added so far. More...
 
const T getSampleMean () const
 Returns the mean of all the values added so far. More...
 
std::size_t getMaximumBlockSize () const
 Returns the largest block size for which there is at least one data point. More...
 
std::size_t getMaximumBlockID () const
 Returns the ID of the largest block size created so far. More...
 
bool hasBlockVariance (const std::size_t blockID) const
 Returns whether the block with the given blockID has enough data to compute a sample variance. More...
 
const T getBlockVariance (const std::size_t blockID) const
 Returns the sample variance in the block with the given blockID. More...
 
const T getBlockStandardDeviation (const std::size_t blockID) const
 Returns the sample standard deviation in the block with the given blockID. More...
 
const T getSampleStandardDeviation () const
 Returns the raw sample standard deviation, i.e. More...
 
const T getBlockStandardErrorOfTheMean (const std::size_t blockID) const
 Returns an estimate for the standard deviation of the standard error of the mean for a given blockID. More...
 
const T getEstimatedStandardDeviationOfBlockStandardErrorOfTheMean (const std::size_t blockID) const
 Returns an estimate for the standard deviation of the standard error of the mean for a given blockID. More...
 
std::size_t getOptimalBlockIDForStandardErrorOfTheMean () const
 Returns the block ID corresponding to the optimal block size, in the sense that the corresponding block provides the most accurate estimate for the standard error of the mean. More...
 
bool optimalStandardErrorOfTheMeanEstimateIsReliable () const
 Returns whether the sample is large enough for the estimate of the standard error of the mean, as provided by the block indicated by getOptimalBlockIDForStandardErrorOfTheMean, to be reliable. More...
 
const T getOptimalStandardErrorOfTheMean () const
 Returns the best estimation of the true standard error of the mean of the data, after decorrelation. More...
 
const std::string serializeToString () const
 Returns a string that contains the state of this instance. More...
 
void unserializeFromString (const std::string &state)
 Discards the current state, and loads the state specified in the given string instead. More...
 

Detailed Description

template<typename T>
class OpenMPCD::OnTheFlyStatisticsDDDA< T >

Computes sample means and their errors for (possibly) serially correlated data.

The algorithm used is called "Dynamic Distributable Decorrelation Algorithm" (DDDA), and is described in [9], which in turn is partly based on [3].

Template Parameters
TThe data type. It must support addition and multiplication of two objects of this type, and division by an unsigned long int.

Definition at line 31 of file OnTheFlyStatisticsDDDA.hpp.

Constructor & Destructor Documentation

◆ OnTheFlyStatisticsDDDA()

The constructor.

Definition at line 20 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.

Member Function Documentation

◆ addDatum()

template<typename T >
void OpenMPCD::OnTheFlyStatisticsDDDA< T >::addDatum ( const T &  datum)

Adds a datum to the sample.

It is assumed that the "time" intervals between subsequently added data are constant; here, "time" may, for example, refer to Molecular Dynamics or Monte Carlo steps.

Parameters
[in]datumThe datum to add.

Definition at line 30 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.

◆ getBlockStandardDeviation()

template<typename T >
const T OpenMPCD::OnTheFlyStatisticsDDDA< T >::getBlockStandardDeviation ( const std::size_t  blockID) const

Returns the sample standard deviation in the block with the given blockID.

Exceptions
OpenMPCD::InvalidArgumentExceptionIf OPENMPCD_DEBUG is defined, throws if blockID is out of range.
OpenMPCD::InvalidCallExceptionThrows if !hasBlockVariance(blockID).
Parameters
[in]blockIDThe block ID, which must be in the range [0, getMaximumBlockID()].

Definition at line 101 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.

◆ getBlockStandardErrorOfTheMean()

template<typename T >
const T OpenMPCD::OnTheFlyStatisticsDDDA< T >::getBlockStandardErrorOfTheMean ( const std::size_t  blockID) const

Returns an estimate for the standard deviation of the standard error of the mean for a given blockID.

Exceptions
OpenMPCD::InvalidArgumentExceptionIf OPENMPCD_DEBUG is defined, throws if blockID is out of range.
OpenMPCD::InvalidCallExceptionThrows if !hasBlockVariance(blockID).
Parameters
[in]blockIDThe block ID, which must be in the range [0, getMaximumBlockID()].

Definition at line 114 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.

◆ getBlockVariance()

template<typename T >
const T OpenMPCD::OnTheFlyStatisticsDDDA< T >::getBlockVariance ( const std::size_t  blockID) const

Returns the sample variance in the block with the given blockID.

Exceptions
OpenMPCD::InvalidArgumentExceptionIf OPENMPCD_DEBUG is defined, throws if blockID is out of range.
OpenMPCD::InvalidCallExceptionThrows if !hasBlockVariance(blockID).
Parameters
[in]blockIDThe block ID, which must be in the range [0, getMaximumBlockID()].

Definition at line 87 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.

◆ getEstimatedStandardDeviationOfBlockStandardErrorOfTheMean()

template<typename T >
const T OpenMPCD::OnTheFlyStatisticsDDDA< T >::getEstimatedStandardDeviationOfBlockStandardErrorOfTheMean ( const std::size_t  blockID) const

Returns an estimate for the standard deviation of the standard error of the mean for a given blockID.

The returned estimate corresponds to Eq. (28) in [3].

Exceptions
OpenMPCD::InvalidArgumentExceptionIf OPENMPCD_DEBUG is defined, throws if blockID is out of range.
OpenMPCD::InvalidCallExceptionThrows if !hasBlockVariance(blockID).
Parameters
[in]blockIDThe block ID, which must be in the range [0, getMaximumBlockID()].

Definition at line 129 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.

◆ getMaximumBlockID()

template<typename T >
std::size_t OpenMPCD::OnTheFlyStatisticsDDDA< T >::getMaximumBlockID

Returns the ID of the largest block size created so far.

Definition at line 68 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.

◆ getMaximumBlockSize()

template<typename T >
std::size_t OpenMPCD::OnTheFlyStatisticsDDDA< T >::getMaximumBlockSize

Returns the largest block size for which there is at least one data point.

Exceptions
OpenMPCD::InvalidCallExceptionThrows if no data have been added so far.

Definition at line 55 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.

◆ getOptimalBlockIDForStandardErrorOfTheMean()

template<typename T >
std::size_t OpenMPCD::OnTheFlyStatisticsDDDA< T >::getOptimalBlockIDForStandardErrorOfTheMean

Returns the block ID corresponding to the optimal block size, in the sense that the corresponding block provides the most accurate estimate for the standard error of the mean.

If there is no variance in the data, 0 is returned.

The algorithm used is described in Section IV of [11].

Exceptions
OpenMPCD::InvalidCallExceptionThrows if fewer than two data points have been added so far.

Definition at line 147 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.

◆ getOptimalStandardErrorOfTheMean()

template<typename T >
const T OpenMPCD::OnTheFlyStatisticsDDDA< T >::getOptimalStandardErrorOfTheMean

Returns the best estimation of the true standard error of the mean of the data, after decorrelation.

See also
optimalStandardErrorOfTheMeanEstimateIsReliable

The algorithm used is described in Section IV of [11].

Exceptions
OpenMPCD::InvalidCallExceptionThrows if fewer than two data points have been added so far.

Definition at line 199 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.

◆ getSampleMean()

template<typename T >
const T OpenMPCD::OnTheFlyStatisticsDDDA< T >::getSampleMean

Returns the mean of all the values added so far.

Since the mean of all values added is returned, and the sample size may not be a power of 2, statistics with different blocking length may not incorporate the same amount of information. This may lead to difficulties when using the error estimates of statistics of different block lengths to estimate the error in the entire, possibly correlated data set, since the statistics of different blocking lengths do not necessarily incorporate the same measurements.

Exceptions
OpenMPCD::InvalidCallExceptionThrows if no data have been added so far.

Definition at line 42 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.

◆ getSampleSize()

template<typename T >
std::size_t OpenMPCD::OnTheFlyStatisticsDDDA< T >::getSampleSize

Returns the number of data points added so far.

Definition at line 36 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.

◆ getSampleStandardDeviation()

template<typename T >
const T OpenMPCD::OnTheFlyStatisticsDDDA< T >::getSampleStandardDeviation

Returns the raw sample standard deviation, i.e.

the sample standard deviation in block 0.

Exceptions
OpenMPCD::InvalidCallExceptionThrows if !hasBlockVariance(0).

Definition at line 108 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.

◆ hasBlockVariance()

template<typename T >
bool OpenMPCD::OnTheFlyStatisticsDDDA< T >::hasBlockVariance ( const std::size_t  blockID) const

Returns whether the block with the given blockID has enough data to compute a sample variance.

Exceptions
OpenMPCD::InvalidArgumentExceptionIf OPENMPCD_DEBUG is defined, throws if blockID is out of range.
Parameters
[in]blockIDThe block ID, which must be in the range [0, getMaximumBlockID()].

Definition at line 76 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.

◆ optimalStandardErrorOfTheMeanEstimateIsReliable()

template<typename T >
bool OpenMPCD::OnTheFlyStatisticsDDDA< T >::optimalStandardErrorOfTheMeanEstimateIsReliable

Returns whether the sample is large enough for the estimate of the standard error of the mean, as provided by the block indicated by getOptimalBlockIDForStandardErrorOfTheMean, to be reliable.

The algorithm used is described in Section IV of [11].

Exceptions
OpenMPCD::InvalidCallExceptionThrows if fewer than two data points have been added so far.

Definition at line 189 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.

◆ serializeToString()

template<typename T >
const std::string OpenMPCD::OnTheFlyStatisticsDDDA< T >::serializeToString

Returns a string that contains the state of this instance.

Since the serialized state is stored a string, it is representing the state only approximately.

Currently, this is implemented only for the cases where boost::is_arithmetic<T>::value is true.

See also
unserializeFromString

Definition at line 235 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.

◆ unserializeFromString()

template<typename T >
void OpenMPCD::OnTheFlyStatisticsDDDA< T >::unserializeFromString ( const std::string &  state)

Discards the current state, and loads the state specified in the given string instead.

Currently, this is implemented only for the cases where boost::is_arithmetic<T>::value is true.

The user is responsible for attempting to load only such serialized states that have been generated with a compatible with T.

Exceptions
InvalidArgumentExceptionThrows if state does not encode a valid state.
Parameters
[in]stateThe state to load. Must be a string created by serializeToString.

Definition at line 260 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.


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