I have recently discovered the excellent library boost::accumulators, and I would like to use it to replace some of my code that accumulates statistics.
One thing I cannot find in the documentation is the ability to sum two accumulator sets, as in operator+=
Example:
using namespace boost::accumulators;
typedef accumulator_set<double, features<tag::variance> > AccumSet;
class Foo {
AccumSet acc;
public:
Foo& operator+=(const Foo& that) {
this->acc += that.acc; // error! no such operator
return *this;
}
double GetVariance() { return variance(acc); }
};
How can I achieve this using the available API? I don't know if this can be implemented for all the types of accumulators in the library (maybe not for tail), but it sure can be for important things, like count, sum, mean, moment, covariance, etc
Unfortunately, this feature is not provided by Boost.Accumulators, probably because combining would only work for some statistics.
There is a ticket on the Boost tracker asking for such a combine
function.
There is no appropriate and available operator+= for adding two accumulator_set<> objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With