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. Flyvbjerg, Error estimates on averages of correlated data, http://dx.doi.org/10.1063/1.457480 Also, see Frenkel and Smit, Understanding Molecular Simulations, Appendix D and Case study 4 (pages 98-100, Figure 4.4).

Arguments

args:

  • num_moments: maximum number of moments (default: 5).

  • max_block_operations: maximum number of blocking operations (default: 6).

Public Functions

int max_block_operations() const

Return the maximum number of block operations.

int num_moments() const

Return the maximum number of moments.

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))

double block_stdev(const int num_op = -1, const int min_blocks = 10) const

Return standard deviation of the block average. Return 0 if not enough data.

param num_op:

Use the given operation. If -1, have the maximum stdev over all blocks.

param min_blocks:

If num_op == -1, minimum number of blocks to consider stdev.

double block_std_of_std(const int num_op = 0) const

Return standard deviation of the standard deviation of the block average.

const std::vector<std::shared_ptr<Accumulator>> &block_averages() const

Return the block averages.

const std::vector<double> &block_size() const

Return the size of each block.

const std::vector<std::vector<double>> &blocks() const

Return the blocks.

const std::vector<double> largest_blocks(const int min = 3) const

Return the blocks of the largest size with three or more.

int largest_block_operation(const int min = 3) const

Return the block operation with the largest blocks that have three or more.

double block_stdev(const Formula &formula, const int min = 3) const

Compute the standard deviation of the block average of a quantity that is a function of the accumulator.

long 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.

double moment(const int index) const

Return the moments as a double. This is the sum of the value^index. Thus, moment(0) is the number of accumulated values. And moment(1) is the sum of the values. moment(2) is the sum of the squared values, etc.

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

Return the moments.

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 int num_op = 0, const bool verbose = false) const

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