49 CHistogram(
const double min,
const double max,
const size_t nBins);
55 double min,
double max,
double binWidth);
63 void add(
const double x);
69 inline void add(
const MAT_VECTOR_LIKE&
x)
71 const size_t N =
x.size();
72 for (
size_t i = 0; i < N; i++) this->
add(static_cast<double>(
x[i]));
77 inline void add(
const std::vector<T>&
x)
79 const size_t N =
x.size();
80 for (
size_t i = 0; i < N; i++) this->
add(static_cast<double>(
x[i]));
99 void getHistogram(std::vector<double>&
x, std::vector<double>& hits)
const;
106 std::vector<double>&
x, std::vector<double>& hits)
const;
This class provides an easy way of computing histograms for unidimensional real valued variables...
std::vector< size_t > m_bins
The bins counter.
CHistogram(const double min, const double max, const size_t nBins)
Constructor.
void add(const std::vector< T > &x)
double m_binSizeInv
((max-min)/nBins)^-1
This base provides a set of functions for maths stuff.
void add(const double x)
Add an element to the histogram.
double m_min
The histogram limits.
void getHistogram(std::vector< double > &x, std::vector< double > &hits) const
Returns the list of bin centers & hit counts.
size_t m_count
The total elements count.
size_t getBinCount(const size_t index) const
Retuns the elements count into the selected bin index, where first one is 0.
double getBinRatio(const size_t index) const
Retuns the ratio in [0,1] range for the selected bin index, where first one is 0. ...
void clear()
Clear the histogram:
CHistogram createWithFixedWidth(double min, double max, double binWidth)
Constructor with a fixed bin width.
void getHistogramNormalized(std::vector< double > &x, std::vector< double > &hits) const
Returns the list of bin centers & hit counts, normalized such as the integral of the histogram...
void add(const MAT_VECTOR_LIKE &x)
Add all the elements from a MRPT container to the histogram.