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.
0, 0, 0, 5
: How would you "pop off" the 5? – Clamberrolling_sum
. Finally, in the rolling sum instance but probably for lots of other cases, you do have to keep all values but you don't have to use them all to compute the new quantity. – Serveracc = {}
– Precocity