使用boost ::蓄电池,我怎么能重置滚动窗口的大小,它保持额外的历史? [英] Using boost::accumulators, how can I reset a rolling window size, does it keep extra history?
问题描述
我期待在了boost ::累加器框架,特别是一对夫妇的rolling_window计算。
I am looking at the boost::accumulator framework, specifically a couple of the rolling_window calculations.
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/stats.hpp>
#include <boost/accumulators/statistics/rolling_mean.hpp>
accumulator_set<int, stats<tag::rolling_mean> > acc(tag::rolling_window::window_size = 3);
正如你看到这里,我已经设置了WINDOW_SIZE是三,使得它保持了最后三个样本的平均值平均只有
As you see here, I have set the window_size to be three, such that it is maintaining the mean average of the last three samples only.
我可以修改的大小在运行时,也许是基于用户设置?
Can I amend that size at run-time, perhaps based on a user setting?
如果是这样,我增加了WINDOW_SIZE确实累加器有,如果它已经看到了比我的新WINDOW_SIZE更多额外的内部状态,否则我将不得不等待额外的价值?
If so, and I increase the window_size does the accumulator have extra internal state if it had already seen more than my new window_size, or would I have to wait for the extra values?
推荐答案
重置升压蓄电池的最佳方式是将其分配到一个新的。例如:
The best way to reset a boost accumulator is to assign it to a new one. For example:
typedef accumulator_set<int, ... template crazyness tags ... > window_acc;
window_acc acc;
acc(1);
acc(2);
...
// reset
acc = window_acc();
其实,交换会在这里pferred $ P $,但accumulator_set没有交换成员= \\
Actually, swap would be preferred here, but accumulator_set doesn't have a swap member =\
这篇关于使用boost ::蓄电池,我怎么能重置滚动窗口的大小,它保持额外的历史?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!