numeric
Public Member Functions | Public Attributes | List of all members
numeric::Histogram Struct Reference

Histogram class, that splits an interval into n regular bins, and counts how often a value is added to a bin. More...

#include <Histogram.hpp>

Inheritance diagram for numeric::Histogram:
numeric::Buckets< size_t >

Public Member Functions

 Histogram (int count, double min_val, double max_val)
 Constructs a histogram where the number of update() calls with a value that all into a bin are counted. More...
 
void update (double value)
 
double getRelative (size_t idx) const
 
size_t total () const
 
- Public Member Functions inherited from numeric::Buckets< size_t >
 Buckets (int count, double min_val, double max_val, const size_t &initial=size_t())
 
const size_t & operator[] (size_t idx) const
 
size_t & operator[] (size_t idx)
 
size_t getIndex (double value) const
 
size_t & get (double value)
 
double getBucketWidth () const
 
double getUpperBound (size_t idx) const
 
double getLowerBound (size_t idx) const
 
double getCenter (size_t idx) const
 
size_t size () const
 

Public Attributes

size_t n
 
- Public Attributes inherited from numeric::Buckets< size_t >
int count
 
double min_val
 
double max_val
 
std::vector< size_t > buckets
 

Detailed Description

Histogram class, that splits an interval into n regular bins, and counts how often a value is added to a bin.

The counts can be recovered using the bracket operator and a bin index.

Histogram h( 10, 0, 10 );
h.update( 1.5 );
h.update( 11 );
for( size_t i=0; i<h.size(); i++ )
cout << h[i] << endl;

Constructor & Destructor Documentation

◆ Histogram()

numeric::Histogram::Histogram ( int  count,
double  min_val,
double  max_val 
)
inline

Constructs a histogram where the number of update() calls with a value that all into a bin are counted.

Parameters
count- number of divisions in the interval, needs to be greater 0
min_val- lower bound for the interval
max_val- upper bound for the interval, needs to be greater than min_val

Member Function Documentation

◆ getRelative()

double numeric::Histogram::getRelative ( size_t  idx) const
inline

return relative count in bin so that the integral over all bins would result in 1.0. Note, that this is the integral and not the sum, so it takes the width of the bins into account.

◆ total()

size_t numeric::Histogram::total ( ) const
inline

total number of values in the bins

◆ update()

void numeric::Histogram::update ( double  value)
inline

Increase the count for the bin, which value fits in by one. This function will assign a value which is less than min_val the first bucket, and greater than max_val to the last bucket.

Parameters
value- value for which the count in the bin should be increased

Member Data Documentation

◆ n

size_t numeric::Histogram::n

The documentation for this struct was generated from the following file: