53 CHistogram(
const double min,
const double max,
const size_t nBins);
59 double min,
double max,
double binWidth)
64 min, max, static_cast<size_t>(ceil((max -
min) / binWidth)));
73 void add(
const double x);
77 template <
typename Derived>
78 inline void add(
const Eigen::MatrixBase<Derived>&
x)
80 const size_t N =
x.size();
81 for (
size_t i = 0; i < N; i++)
82 this->
add(static_cast<const double>(
x(i)));
87 inline void add(
const std::vector<T>&
x)
89 const size_t N =
x.size();
90 for (
size_t i = 0; i < N; i++)
91 this->
add(static_cast<const double>(
x[i]));
110 void getHistogram(std::vector<double>&
x, std::vector<double>& hits)
const;
117 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
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.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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:
static 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...