#include <genesis/utils/math/histogram/accumulator.hpp>
Histogram helper class that collects data and builds a fitting Histogram.
This class can be used to collect data and automatically build a Histogram that fits to the data. It provides factory methods for differnt ways of initializing the Histogram ranges.
The max value used for the build Histogram will be determined using std::nextafter(max, max + 1)
on the max element of the value list. The Histogram uses half-closed ranges like [a, b), so using the next-bigger value ensures that the max element of the Accumulator just fits into the range.
Definition at line 63 of file accumulator.hpp.
Public Member Functions | |
HistogramAccumulator () | |
HistogramAccumulator (const std::vector< double > &values, double weight=1.0) | |
HistogramAccumulator (const std::vector< std::pair< double, double >> &weighted_values) | |
HistogramAccumulator (HistogramAccumulator &&)=default | |
HistogramAccumulator (HistogramAccumulator const &)=default | |
~HistogramAccumulator ()=default | |
void | accumulate (double x, double weight) |
size_t | added_values () const |
Return the number of values that have been added to the Accumulator. More... | |
const_iterator | begin () const |
Histogram | build_uniform_ranges_histogram (size_t num_bins, bool integer_ranges=false) const |
Histogram | build_uniform_ranges_histogram (size_t num_bins, double min, double max) const |
void | clear () |
bool | empty () const |
const_iterator | end () const |
void | increment (double x) |
double | max () const |
double | min () const |
HistogramAccumulator & | operator= (HistogramAccumulator &&)=default |
HistogramAccumulator & | operator= (HistogramAccumulator const &)=default |
size_t | size () const |
void | swap (HistogramAccumulator &other) |
Public Types | |
typedef std::map< double, double >::const_iterator | const_iterator |
|
inline |
Definition at line 77 of file accumulator.hpp.
|
explicit |
Definition at line 45 of file accumulator.cpp.
|
explicit |
Definition at line 54 of file accumulator.cpp.
|
default |
|
default |
|
default |
void accumulate | ( | double | x, |
double | weight | ||
) |
Definition at line 97 of file accumulator.cpp.
size_t added_values | ( | ) | const |
Return the number of values that have been added to the Accumulator.
This is simply the number of function calls to increment() and accumulate(). The count is reset when calling clear().
Definition at line 133 of file accumulator.cpp.
HistogramAccumulator::const_iterator begin | ( | ) | const |
Definition at line 72 of file accumulator.cpp.
Histogram build_uniform_ranges_histogram | ( | size_t | num_bins, |
bool | integer_ranges = false |
||
) | const |
Definition at line 142 of file accumulator.cpp.
Histogram build_uniform_ranges_histogram | ( | size_t | num_bins, |
double | min, | ||
double | max | ||
) | const |
Definition at line 166 of file accumulator.cpp.
void clear | ( | ) |
Definition at line 86 of file accumulator.cpp.
bool empty | ( | ) | const |
Definition at line 122 of file accumulator.cpp.
HistogramAccumulator::const_iterator end | ( | ) | const |
Definition at line 77 of file accumulator.cpp.
void increment | ( | double | x | ) |
Definition at line 92 of file accumulator.cpp.
double max | ( | ) | const |
Definition at line 112 of file accumulator.cpp.
double min | ( | ) | const |
Definition at line 107 of file accumulator.cpp.
|
default |
|
default |
size_t size | ( | ) | const |
Definition at line 117 of file accumulator.cpp.
void swap | ( | HistogramAccumulator & | other | ) |
Definition at line 62 of file accumulator.cpp.
typedef std::map<double, double>::const_iterator const_iterator |
Definition at line 71 of file accumulator.hpp.