31 #include "../../common/WAssert.h"
32 #include "../../common/WLimits.h"
33 #include "../../common/exceptions/WOutOfBounds.h"
34 #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." );
140 if( ( i % ratio == 0 ) && ( i != 0 ) && ( i != m_nInitialBuckets - 1 ) )
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;
Used to find the occurrence frequencies of values in a value set.
virtual size_t getTotalElementCount() const
This returns the number of value set entries added to the histogram.
size_t m_nInitialBuckets
Number of buckets in the initial histogram.
size_t getNInitialBuckets() const
Return the number of initial buckets.
~WValueSetHistogram()
Destructor.
virtual std::pair< double, double > getIntervalForIndex(size_t index) const
Returns the actual interval associated with the given index.
double m_mappedBucketSize
Size of one bucket in the mapped histogram.
double m_minimum
The smallest value.
double m_nbBuckets
The number of buckets.
virtual size_t size() const
Returns the number of buckets in the histogram with the actual mapping.
WValueSetHistogram & operator=(const WValueSetHistogram &other)
Copy assignment.
boost::shared_array< size_t > m_initialBuckets
Pointer to all initial buckets of the histogram.
virtual double getScalarDouble(size_t i) const =0
Indicates invalid element access of a container.
Container which associate values with (uniform width) bins (aka intervals or buckets).
size_t m_nMappedBuckets
Tracks the number of a buckets in the mapped histogram.
virtual void insert(double value)
increment the value by one, contains the logic to find the element place in the array.
double m_initialBucketSize
Size of one bucket in the initial histogram.
double getInitialBucketSize() const
Return the size of one initial bucket.
virtual size_t operator[](size_t index) const
Get the count of the bucket.
boost::shared_array< size_t > m_mappedBuckets
Pointer to all initial buckets of the histogram.
WValueSetHistogram(boost::shared_ptr< WValueSetBase > valueSet, size_t buckets=1000)
Constructor.
void buildHistogram(const WValueSetBase &valueSet)
Actually builds the histogram.
virtual double getBucketSize(size_t index=0) const
Return the size of one bucket.
size_t m_nbTotalElements
The number of elements distributed in the buckets.
Abstract base class to all WValueSets.
virtual size_t at(size_t index) const
Get the count of the bucket.
virtual size_t getIndexForValue(double value) const
Returns the right index to the bucket containing the given value.
boost::shared_array< size_t > getInitialBuckets() const
Return the initial buckets.
double m_maximum
The biggest value.
virtual size_t size() const =0
virtual size_t accumulate(size_t startIndex, size_t endIndex) const
Sums up the buckets in the specified interval.