我正在看boost :: accumulator框架,特别是一些rolling_window计算.
#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);
Run Code Online (Sandbox Code Playgroud)
如您所见,我已将window_size设置为3,这样它只保留最后三个样本的平均值.
我可以在运行时修改该大小,可能是基于用户设置吗?
如果是这样,并且我增加window_size,如果累加器已经看到超过我的新window_size,那么累加器是否具有额外的内部状态,或者我是否必须等待额外的值?
重置升压累加器的最佳方法是将其分配给新的累加器.例如:
typedef accumulator_set<int, ... template crazyness tags ... > window_acc;
window_acc acc;
acc(1);
acc(2);
...
// reset
acc = window_acc();
Run Code Online (Sandbox Code Playgroud)
实际上,这里首选swap,但accumulator_set没有swap成员= \
| 归档时间: |
|
| 查看次数: |
8049 次 |
| 最近记录: |