69 if (data.size() != m_acc_data.size())
70 throw std::runtime_error(
71 "The given data size does not fit the initialized size!");
75 data.begin(), data.end(), m_acc_data.begin(),
78 std::transform(m_acc_data.begin(), m_acc_data.end(), data.begin(),
82 auto const old_mean = a.mean;
84 old_mean + (d - old_mean) / static_cast<double>(m_n);
85 auto const new_m = a.m + (d - old_mean) * (d - new_mean);
86 return {new_mean, new_m};
106inline std::vector<double> Accumulator::variance()
const {
107 std::vector<double> res;
109 res = std::vector<double>(m_acc_data.size(),
110 std::numeric_limits<double>::max());
112 std::transform(m_acc_data.begin(), m_acc_data.end(),
113 std::back_inserter(res),
115 return acc_data.m / (static_cast<double>(m_n) - 1.);
124inline std::vector<double> Accumulator::std_error()
const {
125 auto const var = variance();
126 std::vector<double> err(var.size());
127 std::transform(var.begin(), var.end(), err.begin(), [
this](
double d) {
128 return std::sqrt(d / static_cast<double>(m_n));