OpenMPCD
|
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... | |
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].
T | The 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.
OpenMPCD::OnTheFlyStatisticsDDDA< T >::OnTheFlyStatisticsDDDA |
The constructor.
Definition at line 20 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.
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.
[in] | datum | The datum to add. |
Definition at line 30 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.
const T OpenMPCD::OnTheFlyStatisticsDDDA< T >::getBlockStandardDeviation | ( | const std::size_t | blockID | ) | const |
Returns the sample standard deviation in the block with the given blockID
.
OpenMPCD::InvalidArgumentException | If OPENMPCD_DEBUG is defined, throws if blockID is out of range. |
OpenMPCD::InvalidCallException | Throws if !hasBlockVariance(blockID) . |
[in] | blockID | The block ID, which must be in the range [0, getMaximumBlockID() ]. |
Definition at line 101 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.
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
.
OpenMPCD::InvalidArgumentException | If OPENMPCD_DEBUG is defined, throws if blockID is out of range. |
OpenMPCD::InvalidCallException | Throws if !hasBlockVariance(blockID) . |
[in] | blockID | The block ID, which must be in the range [0, getMaximumBlockID() ]. |
Definition at line 114 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.
const T OpenMPCD::OnTheFlyStatisticsDDDA< T >::getBlockVariance | ( | const std::size_t | blockID | ) | const |
Returns the sample variance in the block with the given blockID
.
OpenMPCD::InvalidArgumentException | If OPENMPCD_DEBUG is defined, throws if blockID is out of range. |
OpenMPCD::InvalidCallException | Throws if !hasBlockVariance(blockID) . |
[in] | blockID | The block ID, which must be in the range [0, getMaximumBlockID() ]. |
Definition at line 87 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.
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].
OpenMPCD::InvalidArgumentException | If OPENMPCD_DEBUG is defined, throws if blockID is out of range. |
OpenMPCD::InvalidCallException | Throws if !hasBlockVariance(blockID) . |
[in] | blockID | The block ID, which must be in the range [0, getMaximumBlockID() ]. |
Definition at line 129 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.
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.
std::size_t OpenMPCD::OnTheFlyStatisticsDDDA< T >::getMaximumBlockSize |
Returns the largest block size for which there is at least one data point.
OpenMPCD::InvalidCallException | Throws if no data have been added so far. |
Definition at line 55 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.
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].
OpenMPCD::InvalidCallException | Throws if fewer than two data points have been added so far. |
Definition at line 147 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.
const T OpenMPCD::OnTheFlyStatisticsDDDA< T >::getOptimalStandardErrorOfTheMean |
Returns the best estimation of the true standard error of the mean of the data, after decorrelation.
The algorithm used is described in Section IV of [11].
OpenMPCD::InvalidCallException | Throws if fewer than two data points have been added so far. |
Definition at line 199 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.
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.
OpenMPCD::InvalidCallException | Throws if no data have been added so far. |
Definition at line 42 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.
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.
const T OpenMPCD::OnTheFlyStatisticsDDDA< T >::getSampleStandardDeviation |
Returns the raw sample standard deviation, i.e.
the sample standard deviation in block 0
.
OpenMPCD::InvalidCallException | Throws if !hasBlockVariance(0) . |
Definition at line 108 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.
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.
OpenMPCD::InvalidArgumentException | If OPENMPCD_DEBUG is defined, throws if blockID is out of range. |
[in] | blockID | The block ID, which must be in the range [0, getMaximumBlockID()] . |
Definition at line 76 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.
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].
OpenMPCD::InvalidCallException | Throws if fewer than two data points have been added so far. |
Definition at line 189 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.
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
.
Definition at line 235 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.
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
.
InvalidArgumentException | Throws if state does not encode a valid state. |
[in] | state | The state to load. Must be a string created by serializeToString . |
Definition at line 260 of file ImplementationDetails/OnTheFlyStatisticsDDDA.hpp.