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

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

Detailed Description

Histogram helper class that collects data and builds a fitting Histogram.

This class can be used to collect data and automatically build a Histogram that fits to the data. It provides factory methods for differnt ways of initializing the Histogram ranges.

The max value used for the build Histogram will be determined using std::nextafter(max, max + 1) on the max element of the value list. The Histogram uses half-closed ranges like [a, b), so using the next-bigger value ensures that the max element of the Accumulator just fits into the range.

Definition at line 62 of file accumulator.hpp.

Public Member Functions

 HistogramAccumulator ()
 
 HistogramAccumulator (const std::vector< double > &values, double weight=1.0)
 
 HistogramAccumulator (const std::vector< std::pair< double, double >> &weighted_values)
 
 HistogramAccumulator (HistogramAccumulator const &)=default
 
 HistogramAccumulator (HistogramAccumulator &&)=default
 
 ~HistogramAccumulator ()=default
 
void accumulate (double x, double weight)
 
size_t added_values () const
 Return the number of values that have been added to the Accumulator. More...
 
const_iterator begin () const
 
Histogram build_uniform_ranges_histogram (size_t num_bins, bool integer_ranges=false) const
 
Histogram build_uniform_ranges_histogram (size_t num_bins, double min, double max) const
 
void clear ()
 
bool empty () const
 
const_iterator end () const
 
void increment (double x)
 
double max () const
 
double min () const
 
HistogramAccumulatoroperator= (HistogramAccumulator const &)=default
 
HistogramAccumulatoroperator= (HistogramAccumulator &&)=default
 
size_t size () const
 
void swap (HistogramAccumulator &other) noexcept
 

Public Types

typedef std::map< double,
double >::const_iterator 
const_iterator
 

Constructor & Destructor Documentation

Definition at line 76 of file accumulator.hpp.

HistogramAccumulator ( const std::vector< double > &  values,
double  weight = 1.0 
)

Definition at line 45 of file accumulator.cpp.

HistogramAccumulator ( const std::vector< std::pair< double, double >> &  weighted_values)

Definition at line 54 of file accumulator.cpp.

~HistogramAccumulator ( )
default

Member Function Documentation

void accumulate ( double  x,
double  weight 
)

Definition at line 97 of file accumulator.cpp.

size_t added_values ( ) const

Return the number of values that have been added to the Accumulator.

This is simply the number of function calls to increment() and accumulate(). The count is reset when calling clear().

Definition at line 133 of file accumulator.cpp.

Definition at line 72 of file accumulator.cpp.

Histogram build_uniform_ranges_histogram ( size_t  num_bins,
bool  integer_ranges = false 
) const

Definition at line 142 of file accumulator.cpp.

Histogram build_uniform_ranges_histogram ( size_t  num_bins,
double  min,
double  max 
) const

Definition at line 166 of file accumulator.cpp.

void clear ( )

Definition at line 86 of file accumulator.cpp.

bool empty ( ) const

Definition at line 122 of file accumulator.cpp.

Definition at line 77 of file accumulator.cpp.

void increment ( double  x)

Definition at line 92 of file accumulator.cpp.

double max ( ) const

Definition at line 112 of file accumulator.cpp.

double min ( ) const

Definition at line 107 of file accumulator.cpp.

HistogramAccumulator& operator= ( HistogramAccumulator const &  )
default
HistogramAccumulator& operator= ( HistogramAccumulator &&  )
default
size_t size ( ) const

Definition at line 117 of file accumulator.cpp.

void swap ( HistogramAccumulator other)
noexcept

Definition at line 62 of file accumulator.cpp.

Member Typedef Documentation

typedef std::map<double, double>::const_iterator const_iterator

Definition at line 70 of file accumulator.hpp.


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