ALPSCore reference
|
#include <autocorr.hpp>
Public Types | |
using | value_type = T |
using | var_type = typename bind< circular_var, T >::var_type |
using | level_acc_type = var_acc< T, circular_var > |
Public Member Functions | |
autocorr_acc (size_t size=1, size_t batch_size=1, size_t granularity=2) | |
void | reset () |
void | set_size (size_t size) |
void | set_batch_size (size_t batch_size) |
void | set_granularity (size_t granularity) |
bool | valid () const |
size_t | size () const |
autocorr_acc & | operator<< (const computed< T > &src) |
autocorr_acc & | operator<< (const autocorr_result< T > &result) |
size_t | count () const |
autocorr_result< T > | result () const |
autocorr_result< T > | finalize () |
size_t | nlevel () const |
const level_acc_type & | level (size_t i) const |
Protected Member Functions | |
void | add (const computed< T > &source, size_t count) |
void | add_level () |
void | finalize_to (autocorr_result< T > &result) |
Friends | |
class | batch_result< T > |
Accumulator for the integrated autocorrelation time.
The integrated autocorrelation time tau_int
of a time series can be defined as the large-n limit of:
1 + 2 * tau_int = var(n) / var(1), (A)
where var(n)
is the sample variance obtained when averaging over batches, each batch being the sum of n
consecutive elements of the series. Given a simulation of N
steps, its corresponding squared error of the mean sq_error
must thus be corrected as:
sq_error = (1 + 2 * tau_int) * var(1) / N (B)
which can be seen as replacing N
with the number of uncorrelated samples. For a finite simulation, a tradeoff must be made between
(1) formal validity of above equations, which improves with n
, (2) statistical uncertainty in tau_int
, which improves with N/n
.
This can be seen by plugging (A) into (B), which just yields the normal error estimate when sampling over bins of size n
.
The class builds up a hierarchy of variance estimates for different batch sizes, starting with n=batch_size
at level 0, and increasing by a factor granularity
at each level. Assuming k
-sized vectors, the estimator scales as O(k * log N)
in memory and O(k * N * log log N)
in runtime.
Definition at line 17 of file autocorr.hpp.
using alps::alea::autocorr_acc< T >::level_acc_type = var_acc<T, circular_var> |
Definition at line 71 of file autocorr.hpp.
using alps::alea::autocorr_acc< T >::value_type = T |
Definition at line 69 of file autocorr.hpp.
using alps::alea::autocorr_acc< T >::var_type = typename bind<circular_var, T>::var_type |
Definition at line 70 of file autocorr.hpp.
alps::alea::autocorr_acc< T >::autocorr_acc | ( | size_t | size = 1 , |
size_t | batch_size = 1 , |
||
size_t | granularity = 2 |
||
) |
Definition at line 15 of file autocorr.cpp.
|
protected |
Definition at line 67 of file autocorr.cpp.
|
protected |
Definition at line 59 of file autocorr.cpp.
|
inline |
Returns sample size, i.e., number of accumulated data points
Definition at line 101 of file autocorr.hpp.
autocorr_result< T > alps::alea::autocorr_acc< T >::finalize | ( | ) |
Frees data associated with accumulator and return result
Definition at line 108 of file autocorr.cpp.
|
protected |
Definition at line 116 of file autocorr.cpp.
|
inline |
Definition at line 111 of file autocorr.hpp.
|
inline |
Definition at line 109 of file autocorr.hpp.
|
inline |
Add computed vector to the accumulator
Definition at line 95 of file autocorr.hpp.
autocorr_acc< T > & alps::alea::autocorr_acc< T >::operator<< | ( | const autocorr_result< T > & | result | ) |
Merge partial result into accumulator
Definition at line 82 of file autocorr.cpp.
void alps::alea::autocorr_acc< T >::reset | ( | ) |
Re-allocate and thus clear all accumulated data
Definition at line 27 of file autocorr.cpp.
autocorr_result< T > alps::alea::autocorr_acc< T >::result | ( | ) | const |
Returns result corresponding to current state of accumulator
Definition at line 99 of file autocorr.cpp.
void alps::alea::autocorr_acc< T >::set_batch_size | ( | size_t | batch_size | ) |
Update the batch size and discard all measurements
Definition at line 43 of file autocorr.cpp.
void alps::alea::autocorr_acc< T >::set_granularity | ( | size_t | granularity | ) |
Update the increment between levels and discard all measurements
Definition at line 51 of file autocorr.cpp.
void alps::alea::autocorr_acc< T >::set_size | ( | size_t | size | ) |
Update the size and discard all measurements
Definition at line 36 of file autocorr.cpp.
|
inline |
Number of components of the random vector (e.g., size of mean)
Definition at line 92 of file autocorr.hpp.
|
inline |
Returns false
if finalize()
has been called, true
otherwise
Definition at line 89 of file autocorr.hpp.
|
friend |
Definition at line 124 of file autocorr.hpp.