32 #include "../../common/WAssert.h"
33 #include "../../common/WLimits.h"
34 #include "../../common/exceptions/WOutOfBounds.h"
35 #include "../WDataHandlerEnums.h"
36 #include "WValueSetHistogram.h"
39 WHistogram( valueSet->getMinimumValue(), valueSet->getMaximumValue(), buckets )
45 WHistogram( valueSet.getMinimumValue(), valueSet.getMaximumValue(), buckets )
67 WAssert(
m_nbBuckets > 1,
"WValueSetHistogram::buildHistogram : number of buckets needs to be larger than 1." );
70 WAssert(
m_initialBucketSize > 0.0,
"WValueSetHistogram::buildHistogram() : m_initialBucketSize to small." );
90 for(
size_t i = 0; i < valueSet.
size(); ++i )
101 m_initialBucketSize( histogram.m_initialBucketSize ),
102 m_initialBuckets( histogram.m_initialBuckets ),
103 m_nInitialBuckets( histogram.m_nInitialBuckets ),
104 m_mappedBuckets( histogram.m_mappedBuckets ),
105 m_nMappedBuckets( histogram.m_nMappedBuckets ),
106 m_mappedBucketSize( histogram.m_mappedBucketSize ),
107 m_nbTotalElements( histogram.m_nbTotalElements )
115 WAssert( buckets > 1,
"WValueSetHistogram::WValueSetHistogram : number of buckets needs to be larger than 1." );
117 "WValueSetHistogram::WValueSetHistogram : number of buckets needs to be smaller than the initial bucket count." );
205 WAssert( index <
m_nMappedBuckets,
"WValueSetHistogram::at() : index out of range." );
225 return std::make_pair( first, second );
230 if( startIndex > endIndex )
232 std::swap( startIndex, endIndex );
236 if( endIndex >
size() )
238 throw WOutOfBounds( std::string(
"The specified endIndex is out of bounds." ) );
243 while( startIndex != endIndex )
253 for(
size_t i = 0; i < h.
size() - 1; ++i )
258 out << interval.first <<
" " << interval.second <<
" " << std::min( h[ i ],
size_t( 3000 ) ) << std::endl;
Container which associate values with (uniform width) bins (aka intervals or buckets).
double m_minimum
The smallest value.
double m_nbBuckets
The number of buckets.
double m_maximum
The biggest value.
Indicates invalid element access of a container.
Abstract base class to all WValueSets.
virtual size_t size() const =0
virtual double getScalarDouble(size_t i) const =0
Used to find the occurrence frequencies of values in a value set.
virtual size_t accumulate(size_t startIndex, size_t endIndex) const
Sums up the buckets in the specified interval.
double m_mappedBucketSize
Size of one bucket in the mapped histogram.
virtual size_t at(size_t index) const
Get the count of the bucket.
WValueSetHistogram(std::shared_ptr< WValueSetBase > valueSet, size_t buckets=1000)
Constructor.
boost::shared_array< size_t > getInitialBuckets() const
Return the initial buckets.
boost::shared_array< size_t > m_initialBuckets
Pointer to all initial buckets of the histogram.
size_t getNInitialBuckets() const
Return the number of initial buckets.
size_t m_nInitialBuckets
Number of buckets in the initial histogram.
virtual size_t getIndexForValue(double value) const
Returns the right index to the bucket containing the given value.
virtual void insert(double value)
increment the value by one, contains the logic to find the element place in the array.
virtual size_t getTotalElementCount() const
This returns the number of value set entries added to the histogram.
double getInitialBucketSize() const
Return the size of one initial bucket.
virtual double getBucketSize(size_t index=0) const
Return the size of one bucket.
double m_initialBucketSize
Size of one bucket in the initial histogram.
virtual size_t operator[](size_t index) const
Get the count of the bucket.
void buildHistogram(const WValueSetBase &valueSet)
Actually builds the histogram.
size_t m_nMappedBuckets
Tracks the number of a buckets in the mapped histogram.
virtual size_t size() const
Returns the number of buckets in the histogram with the actual mapping.
virtual std::pair< double, double > getIntervalForIndex(size_t index) const
Returns the actual interval associated with the given index.
WValueSetHistogram & operator=(const WValueSetHistogram &other)
Copy assignment.
size_t m_nbTotalElements
The number of elements distributed in the buckets.
~WValueSetHistogram()
Destructor.
boost::shared_array< size_t > m_mappedBuckets
Pointer to all initial buckets of the histogram.