triqs::stat::mean_and_err
#include <triqs/stat.hpp>
Synopsis
template<typename V>auto mean_and_err (V const & data)
Calculate arithmetic mean and standard error [REF] of data in an iterable container.
Template parameters
V Iterable type. Pre-conditions: elements must be: addable to each other, have element-wise multiplication, have complex conjugation defined via conj [REF] .
Parameters
data Container with data
Returns
std::pair with [mean, standard error]; types are deduced from first element of data
Example
#include <triqs/stat/mean_error.hpp>
using namespace triqs::stat;
int main() {
std::vector<double> data{1., 2., 3., 4.};
auto [ave, err] = mean_and_err(data);
std::cout << "Average: " << ave << "\n"; // = 2.5
std::cout << "Standard Error: " << err << std::endl; // = sqrt(5. / 12)
}
Output
Average: 2.5
Standard Error: 0.645497