In Boost.Accumulator, you can add samples to an accumulator and then extract statistical quantities from it. e.g:
acc(1.)
acc(2.)
acc(3.)
cout << mean; // 2
The library has lots of more complicated statistical quantities, such as skewness
, kurtosis
, or p_square_cumulative_distribution
.
What I'd like to do is something like this:
acc(1.)
acc(2.)
acc(3.)
std::cout << mean(acc); // 2
acc.pop() // withdraw the first value (1.)
std::cout << mean(acc); // 2.5
pop()
would work in a FIFO (First In First Out) manner. What I'm trying to do is calculate stats stuffs on my data in an on-line (incremental) fashion within a sliding time-window.
The accumulator would have to internally keep all the values.
I could do my own but I always like to check first for existing libraries, and there may be algorithm I'm not aware of that smartly compute the quantities when data is incoming or outgoing.