25 #ifndef ALEXANDRIA_HISTOGRAM_BINNING_SCOTT_H 26 #define ALEXANDRIA_HISTOGRAM_BINNING_SCOTT_H 31 #include <boost/accumulators/accumulators.hpp> 32 #include <boost/accumulators/statistics/stats.hpp> 33 #include <boost/accumulators/statistics/max.hpp> 34 #include <boost/accumulators/statistics/min.hpp> 35 #include <boost/accumulators/statistics/variance.hpp> 53 template<
typename VarType>
57 template<
typename Iterator>
59 using namespace boost::accumulators;
61 accumulator_set<VarType, stats<tag::variance, tag::max, tag::min>> acc;
62 std::for_each(begin, end, std::bind<void>(std::ref(acc), std::placeholders::_1));
64 size_t n = end - begin;
66 VarType sigma = std::sqrt(variance(acc));
67 VarType h = 3.5 * sigma / std::pow(n, 1. / 3.);
68 VarType vmin = min(acc);
69 VarType vmax = max(acc);
77 VarType range = vmax - vmin;
92 std::pair<VarType, VarType>
getBinEdges(
size_t i)
const final {
109 #endif // ALEXANDRIA_HISTOGRAM_BINNING_SCOTT_H
ssize_t getBinIndex(VarType value) const final
VarType getEdge(size_t i) const final
std::pair< VarType, VarType > getBinEdges(size_t i) const final
void computeBins(Iterator begin, Iterator end)