我Histogram
在我的代码中创建了一个类,该类旨在作为boost::accumulators::accumulator_set
Boost 1.54 的包装器。对我的问题来说似乎很重要的是Histogram.hpp
文件中的那些行:
using namespace boost::accumulators;
class Histogram {
public:
Histogram(int bins, size_t cache);
accumulator_set<double,
features<tag::min, tag::max, tag::mean, tag::density>> acc;
};
然后在Histogram.cpp
我有构造函数:
Histogram::Histogram(int bins, size_t cache)
: acc(accumulator_set<double,
features<tag::min, tag::max, tag::mean, tag::density>>(
tag::density::num_bins = bins,
tag::density::cache_size = std::min(cache, MAX_CACHE_ENTRIES))) {
}
使用此直方图 ( do_iterations()
in main-metropolis.cpp
) 的代码以以下内容开头:
Histogram position_histogram{settings.position_hist_bins, settings.time_sites * settings.iterations};
//Histogram action_histogram{settings.action_hist_bins, settings.iterations};
当我在第二行停用的情况下运行它时,它就像我期望的那样工作。我的模拟生成了一些数据点,将其放入,Histogram::acc
然后让我提取它:
-2.86958 0
-2.37393 0.0002
-1.87829 0.0071
-1.38265 0.06621
-0.887001 0.23902
-0.391356 0.33247
0.104288 0.2342
0.599932 0.08449
1.09558 0.02843
1.59122 0.00775
2.08687 0.00012
2.58251 1e-05
# Min -2.37393
# Max 2.58251
# Mean -0.0809983
然后我激活了这条线,并且position_histogram
以一种非常奇怪的方式工作。bins 全部为零,但数据被分配到第一个和最后一个 bin 的溢出 bin 中:
0 0.57785
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0.42215
# Min -2.37393
# Max 2.58251
# Mean -0.0809983
如果我交换线路,那就是action_histogram
中断。所以第二个总是打破第一个。为什么初始化第二个Histogram
,因此第二个accumulator_set
会导致第一个中断?
d3081a1ef7
请在浏览代码时使用修订版,因为我现在构建了自己的直方图实现以继续工作。