A library for working with phylogenetic and population genetic data.
v0.32.0
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 63 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 &&)=default
 
 HistogramAccumulator (HistogramAccumulator const &)=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 &&)=default
 
HistogramAccumulatoroperator= (HistogramAccumulator const &)=default
 
size_t size () const
 
void swap (HistogramAccumulator &other)
 

Public Types

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

Constructor & Destructor Documentation

◆ HistogramAccumulator() [1/5]

Definition at line 77 of file accumulator.hpp.

◆ HistogramAccumulator() [2/5]

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

Definition at line 45 of file accumulator.cpp.

◆ HistogramAccumulator() [3/5]

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

Definition at line 54 of file accumulator.cpp.

◆ ~HistogramAccumulator()

~HistogramAccumulator ( )
default

◆ HistogramAccumulator() [4/5]

◆ HistogramAccumulator() [5/5]

Member Function Documentation

◆ accumulate()

void accumulate ( double  x,
double  weight 
)

Definition at line 97 of file accumulator.cpp.

◆ added_values()

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.

◆ begin()

Definition at line 72 of file accumulator.cpp.

◆ build_uniform_ranges_histogram() [1/2]

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

Definition at line 142 of file accumulator.cpp.

◆ build_uniform_ranges_histogram() [2/2]

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

Definition at line 166 of file accumulator.cpp.

◆ clear()

void clear ( )

Definition at line 86 of file accumulator.cpp.

◆ empty()

bool empty ( ) const

Definition at line 122 of file accumulator.cpp.

◆ end()

Definition at line 77 of file accumulator.cpp.

◆ increment()

void increment ( double  x)

Definition at line 92 of file accumulator.cpp.

◆ max()

double max ( ) const

Definition at line 112 of file accumulator.cpp.

◆ min()

double min ( ) const

Definition at line 107 of file accumulator.cpp.

◆ operator=() [1/2]

HistogramAccumulator& operator= ( HistogramAccumulator &&  )
default

◆ operator=() [2/2]

HistogramAccumulator& operator= ( HistogramAccumulator const &  )
default

◆ size()

size_t size ( ) const

Definition at line 117 of file accumulator.cpp.

◆ swap()

void swap ( HistogramAccumulator other)

Definition at line 62 of file accumulator.cpp.

Member Typedef Documentation

◆ const_iterator

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

Definition at line 71 of file accumulator.hpp.


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