Tomographer
v1.0a
Tomographer C++ Framework Documentation
|
Stores a histogram. More...
#include <tomographer/histogram.h>
Classes | |
struct | Params |
The parameters of a UniformBinsHistogram. More... | |
Public Types | |
typedef Scalar_ | Scalar |
The scalar type of the "X"-axis of the histogram (usually double ) | |
typedef CountType_ | CountType |
The type that serves to count how many hits in each bin. | |
Public Member Functions | |
UniformBinsHistogram (Params p=Params()) | |
Constructor: stores the parameters and initializes the histogram to zero counts everywhere. | |
UniformBinsHistogram (Scalar min_, Scalar max_, std::size_t num_bins) | |
Constructor: stores the parameters and initializes the histogram to zero counts everywhere. | |
template<typename HistogramType > | |
UniformBinsHistogram (const HistogramType &other) | |
Constructor: copy another histogram type. | |
void | reset () |
Resets the histogram to zero counts everywhere. | |
template<typename EigenType > | |
void | load (const Eigen::DenseBase< EigenType > &x, CountType off_chart_=0) |
Load data for the histogram. Uses current histogram parameters, just sets the bin counts. More... | |
template<typename EigenType > | |
void | add (const Eigen::ArrayBase< EigenType > &x, CountType off_chart_=0) |
Add data to the histogram. More... | |
template<typename OtherScalar , typename OtherCountType > | |
void | add (const UniformBinsHistogram< OtherScalar, OtherCountType > &x) |
Add data to the histogram. More... | |
std::size_t | num_bins () const |
Shorthand for params.num_bins | |
CountType | count (std::size_t i) const |
Shorthand for bins(i) | |
bool | is_within_bounds (Scalar value) const |
Shorthand for params.is_within_bounds(value) | |
std::size_t | bin_index (Scalar value) const |
Shorthand for params.bin_index(value) | |
Scalar | bin_lower_value (int index) const |
Shorthand for params.bin_lower_value(index) | |
Scalar | bin_center_value (std::size_t index) const |
Shorthand for params.bin_center_value(index) | |
Scalar | bin_upper_value (std::size_t index) const |
Shorthand for params.bin_upper_value(index) | |
Scalar | bin_resolution () const |
Shorthand for params.bin_resolution() | |
std::size_t | record (Scalar value) |
Record a new value in the histogram. More... | |
std::size_t | record (Scalar value, CountType weight) |
Record a new value in the histogram, with a certain weight. More... | |
std::string | pretty_print (int max_width=0) const |
Pretty-print the histogram and return it as a string with horizontal bars. More... | |
Public Attributes | |
Params | params |
Parameters of this histogram (range and # of bins) | |
Eigen::Array< CountType, Eigen::Dynamic, 1 > | bins |
The counts for each bin. | |
CountType | off_chart |
The number of points that fell outside of the given range. | |
Static Public Attributes | |
static constexpr bool | HasErrorBars = false |
This histogram type does not provide error bars (see Histogram Interface) | |
Stores a histogram.
Splits the range of values \([\text{min},\text{max}]\) into num_bins
number of bins, and keeps counts of how many samples fell in which bin.
Does not store any form of error bars. Compiles with the Histogram Interface.
Definition at line 65 of file histogram.h.
|
inline |
Add data to the histogram.
x | is an Eigen Vector or 1-D Array from which to load data to add to the histogram counts. It must be (dense) Eigen::ArrayBase-derived type, have one column and exactly num_bins() rows. |
off_chart_ | if provided, add this amount to the off_chart counts. |
Definition at line 248 of file histogram.h.
|
inline |
Add data to the histogram.
Adds the values contained in the other histogram x to the current histogram. This also updates the off_chart counts.
Definition at line 268 of file histogram.h.
|
inline |
Load data for the histogram. Uses current histogram parameters, just sets the bin counts.
x | is an Eigen Vector or 1-D Array from which to load the data. It must be dense, have one column and exactly num_bins() rows. |
off_chart_ | if provided, then set the off_chart count to this number. Otherwise, reset the off_chart counts to zero. |
Definition at line 231 of file histogram.h.
|
inline |
Pretty-print the histogram and return it as a string with horizontal bars.
max_width | is the maximum line width the display should fit in. |
Definition at line 370 of file histogram.h.
|
inline |
Record a new value in the histogram.
This adds one to the bin corresponding to the given value.
If the value is out of the histogram range, then off_chart is incremented by one.
Returns the index of the bin in which the value was added, or "std::numeric_limits<std::size_t>::max()" if off-chart.
Definition at line 331 of file histogram.h.
|
inline |
Record a new value in the histogram, with a certain weight.
This adds weight to the histogram bin corresponding to the given value.
If the value is out of the histogram range, then off_chart is incremented by weight.
Returns the index of the bin in which the value was added, or "std::numeric_limits<std::size_t>::max()" if off-chart.
Definition at line 353 of file histogram.h.