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};
99inline std::vector<double> Accumulator::variance()
const {
100 std::vector<double> res;
102 res = std::vector<double>(m_acc_data.size(),
103 std::numeric_limits<double>::max());
105 std::transform(m_acc_data.begin(), m_acc_data.end(),
106 std::back_inserter(res),
108 return acc_data.m / (static_cast<double>(m_n) - 1);
117inline std::vector<double> Accumulator::std_error()
const {
118 auto const var = variance();
119 std::vector<double> err(var.size());
120 std::transform(var.begin(), var.end(), err.begin(), [
this](
double d) {
121 return std::sqrt(d / static_cast<double>(m_n));