23 : m_min(min), m_max(max), m_bins(nBins, 0), m_count(0)
45 if (x < m_min || x >
m_max)
return;
78 std::vector<double>& x, std::vector<double>& hits)
const 81 const size_t N =
m_bins.size();
83 for (
size_t i = 0; i < N; i++) hits[i] = static_cast<double>(
m_bins[i]);
87 std::vector<double>& x, std::vector<double>& hits)
const 89 const size_t N =
m_bins.size();
94 for (
size_t i = 0; i < N; i++) hits[i] = K *
m_bins[i];
98 double min,
double max,
double binWidth)
103 min, max, static_cast<size_t>(ceil((max - min) / binWidth)));
This class provides an easy way of computing histograms for unidimensional real valued variables...
#define THROW_EXCEPTION(msg)
std::vector< size_t > m_bins
The bins counter.
CHistogram(const double min, const double max, const size_t nBins)
Constructor.
double m_binSizeInv
((max-min)/nBins)^-1
#define ASSERT_(f)
Defines an assertion mechanism.
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 linspace(T first, T last, size_t count, VECTOR &out_vector)
Generates an equidistant sequence of numbers given the first one, the last one and the desired number...
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:
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...