| 
    MRPT
    2.0.0
    
   | 
 
This class provides an easy way of computing histograms for unidimensional real valued variables.
Call "getHistogram" or "getHistogramNormalized" to retrieve the full list of bin positions & hit counts.
Example:
Definition at line 33 of file CHistogram.h.
#include <mrpt/math/CHistogram.h>
Public Member Functions | |
| CHistogram (const double min, const double max, const size_t nBins) | |
| Constructor.  More... | |
| CHistogram | createWithFixedWidth (double min, double max, double binWidth) | 
| Constructor with a fixed bin width.  More... | |
| void | clear () | 
| Clear the histogram:  More... | |
| void | add (const double x) | 
| Add an element to the histogram.  More... | |
| template<typename MAT_VECTOR_LIKE , typename = typename MAT_VECTOR_LIKE::Scalar> | |
| void | add (const MAT_VECTOR_LIKE &x) | 
| Add all the elements from a MRPT container to the histogram.  More... | |
| template<typename T > | |
| void | add (const std::vector< T > &x) | 
| size_t | getBinCount (const size_t index) const | 
| Retuns the elements count into the selected bin index, where first one is 0.  More... | |
| double | getBinRatio (const size_t index) const | 
| Retuns the ratio in [0,1] range for the selected bin index, where first one is 0.  More... | |
| void | getHistogram (std::vector< double > &x, std::vector< double > &hits) const | 
| Returns the list of bin centers & hit counts.  More... | |
| 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, interpreted as a density PDF, amounts to 1.  More... | |
Private Attributes | |
| double | m_min | 
| The histogram limits.  More... | |
| double | m_max | 
| double | m_binSizeInv | 
| ((max-min)/nBins)^-1  More... | |
| std::vector< size_t > | m_bins | 
| The bins counter.  More... | |
| size_t | m_count | 
| The total elements count.  More... | |
| CHistogram::CHistogram | ( | const double | min, | 
| const double | max, | ||
| const size_t | nBins | ||
| ) | 
Constructor.
| std::exception | On nBins<=0 or max<=min | 
Definition at line 22 of file CHistogram.cpp.
References ASSERT_, m_binSizeInv, m_max, and m_min.
Referenced by createWithFixedWidth().
| void CHistogram::add | ( | const double | x | ) | 
Add an element to the histogram.
If element is out of [min,max] it is ignored.
Definition at line 42 of file CHistogram.cpp.
References ASSERT_, m_bins, m_binSizeInv, m_count, m_max, and m_min.
Referenced by add(), mrpt::math::CMonteCarlo< T, NUM, OTHER >::CStatisticalAnalyzer::getDistribution(), mrpt::math::histogram(), and TEST().
      
  | 
  inline | 
Add all the elements from a MRPT container to the histogram.
If an element is out of [min,max] it is ignored.
Definition at line 69 of file CHistogram.h.
References add().
      
  | 
  inline | 
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 77 of file CHistogram.h.
References add().
| void CHistogram::clear | ( | ) | 
Clear the histogram:
Definition at line 33 of file CHistogram.cpp.
References m_bins, and m_count.
Referenced by TEST().
      
  | 
  inline | 
Constructor with a fixed bin width.
| std::exception | On max<=min or width<=0 | 
Definition at line 97 of file CHistogram.cpp.
References ASSERT_, and CHistogram().
Referenced by mrpt::math::CMonteCarlo< T, NUM, OTHER >::CStatisticalAnalyzer::getDistribution().
| size_t CHistogram::getBinCount | ( | const size_t | index | ) | const | 
Retuns the elements count into the selected bin index, where first one is 0.
| std::exception | On invalid index | 
Definition at line 57 of file CHistogram.cpp.
References m_bins, and THROW_EXCEPTION.
| double CHistogram::getBinRatio | ( | const size_t | index | ) | const | 
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. | 
Definition at line 67 of file CHistogram.cpp.
References m_bins, m_count, and THROW_EXCEPTION.
| void CHistogram::getHistogram | ( | std::vector< double > & | x, | 
| std::vector< double > & | hits | ||
| ) | const | 
Returns the list of bin centers & hit counts.
Definition at line 77 of file CHistogram.cpp.
References mrpt::math::linspace(), m_bins, m_max, and m_min.
Referenced by mrpt::math::histogram(), and TEST().
| void CHistogram::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, interpreted as a density PDF, amounts to 1.
Definition at line 86 of file CHistogram.cpp.
References mrpt::math::linspace(), m_bins, m_binSizeInv, m_count, m_max, and m_min.
Referenced by mrpt::math::histogram().
      
  | 
  private | 
The bins counter.
Definition at line 41 of file CHistogram.h.
Referenced by add(), clear(), getBinCount(), getBinRatio(), getHistogram(), and getHistogramNormalized().
      
  | 
  private | 
((max-min)/nBins)^-1
Definition at line 39 of file CHistogram.h.
Referenced by add(), CHistogram(), and getHistogramNormalized().
      
  | 
  private | 
The total elements count.
Definition at line 43 of file CHistogram.h.
Referenced by add(), clear(), getBinRatio(), and getHistogramNormalized().
      
  | 
  private | 
Definition at line 37 of file CHistogram.h.
Referenced by add(), CHistogram(), getHistogram(), and getHistogramNormalized().
      
  | 
  private | 
The histogram limits.
Definition at line 37 of file CHistogram.h.
Referenced by add(), CHistogram(), getHistogram(), and getHistogramNormalized().
| Page generated by Doxygen 1.8.14 for MRPT 2.0.0 Git: b38439d21 Tue Mar 31 19:58:06 2020 +0200 at miƩ abr 1 00:50:30 CEST 2020 |