A toolkit for working with phylogenetic data.
v0.19.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Histogram Class Reference

#include <genesis/utils/math/histogram.hpp>

Detailed Description

Histogram class for accumulating and summarizing data.

Many details of the implementation are taken from the GNU Scientific Library: https://www.gnu.org/software/gsl/manual/html_node/Histograms.html See there for some more information.

The structure of the kept data is as follows:

   [ bin[0] )[ bin[1] )[ bin[2] )[ bin[3] )[ bin[4] )
---|---------|---------|---------|---------|---------|---  x
 r[0]      r[1]      r[2]      r[3]      r[4]      r[5]

The number of bins needs to be determined at construction. The number of ranges is always one more than the number of bins.

Definition at line 68 of file histogram.hpp.

Public Member Functions

 Histogram (size_t num_bins)
 
 Histogram (size_t num_bins, double range_min, double range_max)
 
 Histogram (const std::vector< double > &ranges)
 
 Histogram (Histogram const &)=default
 
 Histogram (Histogram &&)=default
 
 ~Histogram ()=default
 
int accumulate (double x, double weight)
 
void accumulate_bin (size_t bin, double weight)
 
double & at (size_t bin_num)
 
double at (size_t bin_num) const
 
iterator begin ()
 
const_iterator begin () const
 
double bin_midpoint (size_t bin_num) const
 
std::pair< double, double > bin_range (size_t bin_num) const
 
double bin_width (size_t bin_num) const
 
size_t bins () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
bool check_range (double x) const
 
void clear ()
 
iterator end ()
 
const_iterator end () const
 
int find_bin (double x) const
 
int increment (double x)
 
void increment_bin (size_t bin)
 
Histogramoperator= (Histogram const &)=default
 
Histogramoperator= (Histogram &&)=default
 
bool operator== (Histogram const &rhs)
 
double & operator[] (size_t bin_num)
 
double operator[] (size_t bin_num) const
 
OutOfRangeBehaviour out_of_range_behaviour () const
 
void out_of_range_behaviour (OutOfRangeBehaviour v)
 
double range_max () const
 
double range_min () const
 
void set_ranges (const std::vector< double > &ranges)
 
void set_uniform_ranges (const double min, const double max)
 

Public Types

typedef std::vector< double >
::const_iterator 
const_iterator
 
typedef std::vector< double >
::iterator 
iterator
 
enum  OutOfRangeBehaviour { kSqueeze, kIgnore, kThrow }
 

Friends

bool equal_ranges (Histogram const &lhs, Histogram const &rhs)
 
void swap (Histogram &lhs, Histogram &rhs)
 

Constructor & Destructor Documentation

Histogram ( size_t  num_bins)

Definition at line 64 of file histogram.cpp.

Histogram ( size_t  num_bins,
double  range_min,
double  range_max 
)

Definition at line 72 of file histogram.cpp.

Histogram ( const std::vector< double > &  ranges)

Definition at line 88 of file histogram.cpp.

~Histogram ( )
default
Histogram ( Histogram const &  )
default
Histogram ( Histogram &&  )
default

Member Function Documentation

int accumulate ( double  x,
double  weight 
)

Definition at line 317 of file histogram.cpp.

void accumulate_bin ( size_t  bin,
double  weight 
)

Definition at line 351 of file histogram.cpp.

double & at ( size_t  bin_num)

Definition at line 180 of file histogram.cpp.

double at ( size_t  bin_num) const

Definition at line 188 of file histogram.cpp.

Definition at line 210 of file histogram.cpp.

Histogram::const_iterator begin ( ) const

Definition at line 220 of file histogram.cpp.

double bin_midpoint ( size_t  bin_num) const

Definition at line 254 of file histogram.cpp.

std::pair< double, double > bin_range ( size_t  bin_num) const

Definition at line 249 of file histogram.cpp.

double bin_width ( size_t  bin_num) const

Definition at line 259 of file histogram.cpp.

size_t bins ( ) const

Definition at line 244 of file histogram.cpp.

Histogram::const_iterator cbegin ( ) const

Definition at line 230 of file histogram.cpp.

Histogram::const_iterator cend ( ) const

Definition at line 235 of file histogram.cpp.

bool check_range ( double  x) const

Definition at line 303 of file histogram.cpp.

void clear ( )

Definition at line 150 of file histogram.cpp.

Definition at line 215 of file histogram.cpp.

Definition at line 225 of file histogram.cpp.

int find_bin ( double  x) const

Definition at line 264 of file histogram.cpp.

int increment ( double  x)

Definition at line 312 of file histogram.cpp.

void increment_bin ( size_t  bin)

Definition at line 346 of file histogram.cpp.

Histogram& operator= ( Histogram const &  )
default
Histogram& operator= ( Histogram &&  )
default
bool operator== ( Histogram const &  rhs)

Definition at line 171 of file histogram.cpp.

double & operator[] ( size_t  bin_num)

Definition at line 196 of file histogram.cpp.

double operator[] ( size_t  bin_num) const

Definition at line 201 of file histogram.cpp.

Histogram::OutOfRangeBehaviour out_of_range_behaviour ( ) const

Definition at line 157 of file histogram.cpp.

void out_of_range_behaviour ( OutOfRangeBehaviour  v)

Definition at line 162 of file histogram.cpp.

double range_max ( ) const

Definition at line 298 of file histogram.cpp.

double range_min ( ) const

Definition at line 293 of file histogram.cpp.

void set_ranges ( const std::vector< double > &  ranges)

Definition at line 107 of file histogram.cpp.

void set_uniform_ranges ( const double  min,
const double  max 
)

Definition at line 120 of file histogram.cpp.

Friends And Related Function Documentation

bool equal_ranges ( Histogram const &  lhs,
Histogram const &  rhs 
)
friend

Definition at line 55 of file histogram.cpp.

void swap ( Histogram lhs,
Histogram rhs 
)
friend

Definition at line 47 of file histogram.cpp.

Member Typedef Documentation

typedef std::vector<double>::const_iterator const_iterator

Definition at line 83 of file histogram.hpp.

typedef std::vector<double>::iterator iterator

Definition at line 82 of file histogram.hpp.

Member Enumeration Documentation

enum OutOfRangeBehaviour
strong
Enumerator
kSqueeze 
kIgnore 
kThrow 

Definition at line 76 of file histogram.hpp.


The documentation for this class was generated from the following files: