#include <genesis/utils/math/histogram.hpp>
Histogram class for accumulating and summarizing data.
Many details of the implementation are taken from the GNU Scientific Library: https://www.gnu.org/software/gsl/manual/html_node/Histograms.html See there for some more information.
The structure of the kept data is as follows:
[ bin[0] )[ bin[1] )[ bin[2] )[ bin[3] )[ bin[4] ) ---|---------|---------|---------|---------|---------|--- x r[0] r[1] r[2] r[3] r[4] r[5]
The number of bins needs to be determined at construction. The number of ranges is always one more than the number of bins.
Definition at line 68 of file histogram.hpp.
Public Member Functions | |
Histogram ()=default | |
Histogram (const std::vector< double > &ranges) | |
Histogram (Histogram &&)=default | |
Histogram (Histogram const &)=default | |
Histogram (size_t num_bins) | |
Histogram (size_t num_bins, double range_min, double range_max) | |
~Histogram ()=default | |
long | accumulate (double x, double weight) |
void | accumulate_bin (size_t bin, double weight) |
double & | at (size_t bin_num) |
double | at (size_t bin_num) const |
iterator | begin () |
const_iterator | begin () const |
double | bin_midpoint (size_t bin_num) const |
std::pair< double, double > | bin_range (size_t bin_num) const |
double | bin_width (size_t bin_num) const |
size_t | bins () const |
const_iterator | cbegin () const |
const_iterator | cend () const |
bool | check_range (double x) const |
void | clear () |
iterator | end () |
const_iterator | end () const |
long | find_bin (double x) const |
long | increment (double x) |
void | increment_bin (size_t bin) |
Histogram & | operator= (Histogram &&)=default |
Histogram & | operator= (Histogram const &)=default |
bool | operator== (Histogram const &rhs) |
double & | operator[] (size_t bin_num) |
double | operator[] (size_t bin_num) const |
OutOfRangeBehaviour | out_of_range_behaviour () const |
void | out_of_range_behaviour (OutOfRangeBehaviour v) |
double | range_max () const |
double | range_min () const |
void | set_ranges (const std::vector< double > &ranges) |
void | set_uniform_ranges (const double min, const double max) |
Public Types | |
typedef std::vector< double >::const_iterator | const_iterator |
typedef std::vector< double >::iterator | iterator |
enum | OutOfRangeBehaviour { kSqueeze, kIgnore, kThrow } |
Friends | |
bool | equal_ranges (Histogram const &lhs, Histogram const &rhs) |
void | swap (Histogram &lhs, Histogram &rhs) |
|
default |
|
explicit |
Definition at line 64 of file histogram.cpp.
Histogram | ( | size_t | num_bins, |
double | range_min, | ||
double | range_max | ||
) |
Definition at line 72 of file histogram.cpp.
|
explicit |
Definition at line 88 of file histogram.cpp.
|
default |
long accumulate | ( | double | x, |
double | weight | ||
) |
Definition at line 320 of file histogram.cpp.
void accumulate_bin | ( | size_t | bin, |
double | weight | ||
) |
Definition at line 354 of file histogram.cpp.
double & at | ( | size_t | bin_num | ) |
Definition at line 180 of file histogram.cpp.
double at | ( | size_t | bin_num | ) | const |
Definition at line 188 of file histogram.cpp.
Histogram::const_iterator begin | ( | ) |
Definition at line 210 of file histogram.cpp.
const_iterator begin | ( | ) | const |
double bin_midpoint | ( | size_t | bin_num | ) | const |
Definition at line 254 of file histogram.cpp.
std::pair< double, double > bin_range | ( | size_t | bin_num | ) | const |
Definition at line 249 of file histogram.cpp.
double bin_width | ( | size_t | bin_num | ) | const |
Definition at line 259 of file histogram.cpp.
size_t bins | ( | ) | const |
Definition at line 244 of file histogram.cpp.
Histogram::const_iterator cbegin | ( | ) | const |
Definition at line 230 of file histogram.cpp.
Histogram::const_iterator cend | ( | ) | const |
Definition at line 235 of file histogram.cpp.
bool check_range | ( | double | x | ) | const |
Definition at line 306 of file histogram.cpp.
void clear | ( | ) |
Definition at line 150 of file histogram.cpp.
Histogram::const_iterator end | ( | ) |
Definition at line 215 of file histogram.cpp.
const_iterator end | ( | ) | const |
long find_bin | ( | double | x | ) | const |
Definition at line 264 of file histogram.cpp.
long increment | ( | double | x | ) |
Definition at line 315 of file histogram.cpp.
void increment_bin | ( | size_t | bin | ) |
Definition at line 349 of file histogram.cpp.
bool operator== | ( | Histogram const & | rhs | ) |
Definition at line 171 of file histogram.cpp.
double & operator[] | ( | size_t | bin_num | ) |
Definition at line 196 of file histogram.cpp.
double operator[] | ( | size_t | bin_num | ) | const |
Definition at line 201 of file histogram.cpp.
Histogram::OutOfRangeBehaviour out_of_range_behaviour | ( | ) | const |
Definition at line 157 of file histogram.cpp.
void out_of_range_behaviour | ( | OutOfRangeBehaviour | v | ) |
Definition at line 162 of file histogram.cpp.
double range_max | ( | ) | const |
Definition at line 301 of file histogram.cpp.
double range_min | ( | ) | const |
Definition at line 296 of file histogram.cpp.
void set_ranges | ( | const std::vector< double > & | ranges | ) |
Definition at line 107 of file histogram.cpp.
void set_uniform_ranges | ( | const double | min, |
const double | max | ||
) |
Definition at line 120 of file histogram.cpp.
Definition at line 55 of file histogram.cpp.
Definition at line 47 of file histogram.cpp.
typedef std::vector<double>::const_iterator const_iterator |
Definition at line 83 of file histogram.hpp.
Definition at line 82 of file histogram.hpp.
|
strong |
Enumerator | |
---|---|
kSqueeze | |
kIgnore | |
kThrow |
Definition at line 76 of file histogram.hpp.