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);
67 template <
typename Derived>
70 const size_t N =
x.size();
71 for (
size_t i = 0; i < N; i++)
72 this->
add(static_cast<const 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++)
81 this->
add(static_cast<const double>(
x[i]));
100 void getHistogram(std::vector<double>&
x, std::vector<double>& hits)
const;
107 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.
void add(const Eigen::MatrixBase< Derived > &x)
Add all the elements from a MRPT container to the histogram.
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...