OpenWalnut
1.3.1
|
Container which associate values with (uniform width) bins (aka intervals or buckets). More...
#include <WHistogramBasic.h>
Public Member Functions | |
WHistogramBasic (double min, double max, size_t buckets=1000) | |
Default constructor. | |
WHistogramBasic (const WHistogramBasic &hist) | |
Copy constructor. | |
~WHistogramBasic () | |
Default destructor. | |
virtual size_t | operator[] (size_t index) const |
Get the count of the specified bucket. | |
virtual size_t | at (size_t index) const |
Get the count of the specified bucket. | |
virtual double | getBucketSize (size_t index=0) const |
Return the size of one specific bucket. | |
virtual std::pair< double, double > | getIntervalForIndex (size_t index) const |
Returns the actual interval associated with the given index. | |
size_t | valuesSize () const |
Computes the number of inserted values so far. | |
virtual void | insert (double value) |
Inserts a given value within the given range (min, max) into exactly one bin and increment its size. | |
![]() | |
WHistogram (double min, double max, size_t buckets=1000) | |
Default constructor. | |
WHistogram (const WHistogram &hist) | |
Copy constructor. | |
virtual | ~WHistogram () |
Default destructor. | |
virtual size_t | size () const |
Returns the number of buckets in the histogram with the actual mapping. | |
virtual double | getMinimum () const |
Returns the minimum value. | |
virtual double | getMaximum () const |
Returns the maximum value. |
Private Attributes | |
std::vector< size_t > | m_bins |
Bins to associate with the values. | |
double | m_intervalWidth |
The width of an interval is precomputed to save performance. |
Additional Inherited Members | |
![]() | |
double | m_minimum |
The smallest value. | |
double | m_maximum |
The biggest value. | |
double | m_nbBuckets |
The number of buckets. |
Container which associate values with (uniform width) bins (aka intervals or buckets).
This class implements a very simple and easy to use generic histogram with uniform bucket sizes.
Definition at line 38 of file WHistogramBasic.h.
WHistogramBasic::WHistogramBasic | ( | double | min, |
double | max, | ||
size_t | buckets = 1000 |
||
) |
Default constructor.
Creates an empty histogram covering the specified min and max values with the specified number of buckets.
min | the smallest value |
max | the largest value |
buckets | the number of buckets |
Definition at line 35 of file WHistogramBasic.cpp.
WHistogramBasic::WHistogramBasic | ( | const WHistogramBasic & | hist | ) |
Copy constructor.
Creates a deep copy of the specified histogram.
hist | the histogram to copy. |
Definition at line 42 of file WHistogramBasic.cpp.
WHistogramBasic::~WHistogramBasic | ( | ) |
Default destructor.
Definition at line 50 of file WHistogramBasic.cpp.
|
virtual |
Get the count of the specified bucket.
Testing if the position is valid.
index | which buckets count is to be returned; starts with 0 which is the bucket containing the smallest values. |
Implements WHistogram.
Definition at line 59 of file WHistogramBasic.cpp.
References wlog::error(), and m_bins.
|
virtual |
Return the size of one specific bucket.
index | the width for this bucket is queried. |
Implements WHistogram.
Definition at line 69 of file WHistogramBasic.cpp.
References m_intervalWidth.
|
virtual |
Returns the actual interval associated with the given index.
The interval is open, meaning that getIntervalForIndex( i ).second == getIntervalForIndex( i + 1 ).first but does not belong anymore to the interval itself but every value smaller than getIntervalForIndex( i ).second.
index | the intex |
Implements WHistogram.
Definition at line 74 of file WHistogramBasic.cpp.
References m_intervalWidth, and WHistogram::m_minimum.
|
virtual |
Inserts a given value within the given range (min, max) into exactly one bin and increment its size.
value | Value to insert. |
Definition at line 81 of file WHistogramBasic.cpp.
References wlimits::DBL_EPS, m_bins, WHistogram::m_maximum, WHistogram::m_minimum, WHistogram::m_nbBuckets, and wlog::warn().
Referenced by WHistogramBasicTest::testInsert(), WHistogramBasicTest::testInsertAlmostMax(), WHistogramBasicTest::testInsertMax(), WHistogramBasicTest::testInsertMin(), WHistogramBasicTest::testInsertOnIntervalBorder(), WHistogramBasicTest::testInsertOutOfBounds(), and WHistogramBasicTest::testOperatorToGetNumberOfElementsInsideTheBin().
|
virtual |
Get the count of the specified bucket.
index | which buckets count is to be returned; starts with 0 which is the bucket containing the smallest values. |
Implements WHistogram.
Definition at line 54 of file WHistogramBasic.cpp.
References m_bins.
size_t WHistogramBasic::valuesSize | ( | ) | const |
Computes the number of inserted values so far.
Definition at line 100 of file WHistogramBasic.cpp.
References m_bins.
Referenced by WHistogramBasicTest::testInitialization(), WHistogramBasicTest::testInsert(), and WHistogramBasicTest::testOperatorToGetNumberOfElementsInsideTheBin().
|
private |
Bins to associate with the values.
Each bin has the width of m_intervalWidth;
Definition at line 119 of file WHistogramBasic.h.
Referenced by at(), insert(), operator[](), and valuesSize().
|
private |
The width of an interval is precomputed to save performance.
Definition at line 124 of file WHistogramBasic.h.
Referenced by getBucketSize(), and getIntervalForIndex().