Accumulator

class Accumulator

Accumulate a series of values to compute the average, standard deviation, and the standard deviation of the average of uncorrelated data using the blocking method.

Public Functions

Accumulator(const argtype &args = argtype())

args:

  • num_block: number of values per block (default: 1e5).

void accumulate(double value)

Add a value to the running sum of values and higher moments.

double average() const

Return average of accumulated values.

double stdev() const

Return standard deviation e.g., fluctuation of all (correlated) values.

double std() const

Same as above.

double stdev_of_av() const

Return the standard deviation of the average (e.g., std/sqrt(num_samples))

void set_block(const double num_block = 1e5)

Parameters
  • num_block: number of values per block

Set the size of a block to compute (uncorrelated) standard errors of the block averages.

Flyvbjerg, Error estimates on averages of correlated data, http://dx.doi.org/10.1063/1.457480

double num_block() const

Return number of values per block.

double block_stdev() const

Return standard deviation of the block averages (0 if not enough blocks).

double num_values() const

Return number of values accumulated.

long double sum() const

Return sum of all values accumulated.

double sum_dble() const

Same as above, but truncated to double precision for Python interface.

long double sum_of_squared() const

Return sum of the square of all values accumulated.

double sum_of_squared_dble() const

Same as above, but truncated to double precision for Python interface.

void reset()

Zero all accumulated values.

double max() const

Return the maximum value accumulated.

double min() const

Return the minimum value accumulated.

void set_moments(const int num_moments = 2)

Set the highest order of moments recorded.

std::vector<long double> moments() const

Return the moments.

double moment(const int index) const

Return the moments as a double.

std::string status_header() const

Return the header of the human readable status.

std::string status() const

Return human readable status.

std::string str() const

Combine header and status.

double last_value() const

Return the last value accumulated.

bool is_equivalent(const Accumulator &accumulator, const double t_factor, const bool verbose = false) const

Return true if the Accumulator is equivalent within the given confidence interval based on the block average standard deviations.