#include <mrpt/math/CHistogram.h>
Public Member Functions | ||||
| CHistogram (double min, double max, int nBins) | ||||
Constructor
| ||||
| void | clear () | |||
| Clear the histogram:. | ||||
| void | add (double x) | |||
| Add an element to the histogram. | ||||
| int | getBinCount (int index) | |||
| Retuns the elements count into the selected bin index, where first one is 0. | ||||
| double | getBinRatio (int index) | |||
| Retuns the ratio in [0,1] range for the selected bin index, where first one is 0. | ||||
Private Attributes | ||||
| double | min | |||
| Private members:. | ||||
| double | max | |||
| std::vector< int > | bins | |||
| The bins counter. | ||||
| int | count | |||
| The total elements count. | ||||
How to use it:
CHistogram hist(0,100,10); hist.add(86); hist.add(7); hist.add(45); std::cout << hist.getBinCount(0) << std::endl; // Result: "1" std::cout << hist.getBinRatio(0) << std::endl; // Result: "0.33"
Definition at line 52 of file CHistogram.h.
| mrpt::math::CHistogram::CHistogram | ( | double | min, | |
| double | max, | |||
| int | nBins | |||
| ) |
Constructor
| std::exception | On nBins<=0 or max<=min. |
| void mrpt::math::CHistogram::add | ( | double | x | ) |
Add an element to the histogram.
If element is out [min,max] it is ignored.
Referenced by mrpt::math::histogram().
| void mrpt::math::CHistogram::clear | ( | ) |
Clear the histogram:.
| int mrpt::math::CHistogram::getBinCount | ( | int | index | ) |
Retuns the elements count into the selected bin index, where first one is 0.
| std::exception | On invalid index |
Referenced by mrpt::math::histogram().
| double mrpt::math::CHistogram::getBinRatio | ( | int | index | ) |
Retuns the ratio in [0,1] range for the selected bin index, where first one is 0.
It returns 0 if no elements have been added.
| std::exception | On invalid index. |
Referenced by mrpt::math::histogram().
std::vector<int> mrpt::math::CHistogram::bins [private] |
int mrpt::math::CHistogram::count [private] |
double mrpt::math::CHistogram::max [private] |
Definition at line 57 of file CHistogram.h.
double mrpt::math::CHistogram::min [private] |
| Page generated by Doxygen 1.5.8 for MRPT 0.6.5 SVN: at Thu Feb 26 02:07:47 EST 2009 |