Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
Euclid::Histogram::BinStrategy< VarType > Class Template Referenceabstract

#include <Histogram.h>

Inheritance diagram for Euclid::Histogram::BinStrategy< VarType >:
Inheritance graph
[legend]

Public Member Functions

 BinStrategy ()
 
virtual ~BinStrategy ()=default
 
size_t getBinCount () const
 
virtual ssize_t getBinIndex (VarType value) const =0
 
virtual std::vector< VarType > getEdges () const
 
virtual std::pair< VarType, VarType > getBinEdges (size_t i) const
 
virtual VarType getEdge (size_t e) const =0
 
virtual VarType getBin (size_t i) const
 

Protected Attributes

size_t m_nbins
 

Detailed Description

template<typename VarType>
class Euclid::Histogram::BinStrategy< VarType >

Different binning strategies must implement this interface, plus a templated method called computeBins, which should operate over a pair of (begin, end) iterators.

Template Parameters
VarTypeThe type of the continuous variable. Must be an arithmetic type (either integral or floating point)

Definition at line 50 of file Histogram.h.

Constructor & Destructor Documentation

◆ BinStrategy()

template<typename VarType >
Euclid::Histogram::BinStrategy< VarType >::BinStrategy ( )
inline

Constructor.

m_nbins is to be computed by the concrete implementations

Definition at line 57 of file Histogram.h.

◆ ~BinStrategy()

template<typename VarType >
virtual Euclid::Histogram::BinStrategy< VarType >::~BinStrategy ( )
virtualdefault

Destructor

Member Function Documentation

◆ getBin()

template<typename VarType >
virtual VarType Euclid::Histogram::BinStrategy< VarType >::getBin ( size_t  i) const
inlinevirtual

Get the center of the bin i

Parameters
iBin index
Returns
The value situated at the middle of the bin

The default implementation returns the midpoint between the edges. Concrete implementations can override this with a direct calculation.

Definition at line 121 of file Histogram.h.

References Euclid::Histogram::BinStrategy< VarType >::getBinEdges().

Here is the call graph for this function:

◆ getBinCount()

template<typename VarType >
size_t Euclid::Histogram::BinStrategy< VarType >::getBinCount ( ) const
inline
Returns
The number of bins

Definition at line 67 of file Histogram.h.

References Euclid::Histogram::BinStrategy< VarType >::m_nbins.

◆ getBinEdges()

template<typename VarType >
virtual std::pair< VarType, VarType > Euclid::Histogram::BinStrategy< VarType >::getBinEdges ( size_t  i) const
inlinevirtual

Get the two edges corresponding to the bin i

Parameters
iThe bin index
Returns
The two bin edges

Reimplemented in Euclid::Histogram::Binning::EdgeVector< VarType >, Euclid::Histogram::Binning::Scott< VarType >, and Euclid::Histogram::Binning::Sqrt< VarType >.

Definition at line 101 of file Histogram.h.

References Euclid::Histogram::BinStrategy< VarType >::getEdge(), and std::make_pair().

Referenced by Euclid::Histogram::BinStrategy< VarType >::getBin().

Here is the call graph for this function:

◆ getBinIndex()

template<typename VarType >
virtual ssize_t Euclid::Histogram::BinStrategy< VarType >::getBinIndex ( VarType  value) const
pure virtual

Get the bin index corresponding to the given value

Parameters
valueThe value to map to a bin
Returns
The bin index. If value is outside of the bounds, a negative number or a value bigger or equal to m_nbins can be used to mark the fact

Implemented in Euclid::Histogram::Binning::EdgeVector< VarType >, Euclid::Histogram::Binning::Scott< VarType >, and Euclid::Histogram::Binning::Sqrt< VarType >.

◆ getEdge()

template<typename VarType >
virtual VarType Euclid::Histogram::BinStrategy< VarType >::getEdge ( size_t  e) const
pure virtual

Get the edge value e. Note that there are always one more edge than bins: i.e. the bin 0 has the edges (0, 1), the bin 1 the edges (1, 2), etc...

Implemented in Euclid::Histogram::Binning::EdgeVector< VarType >, Euclid::Histogram::Binning::Scott< VarType >, and Euclid::Histogram::Binning::Sqrt< VarType >.

Referenced by Euclid::Histogram::BinStrategy< VarType >::getBinEdges().

◆ getEdges()

template<typename VarType >
virtual std::vector< VarType > Euclid::Histogram::BinStrategy< VarType >::getEdges ( ) const
inlinevirtual
Returns
The list of bin edges

The default implementation is based on getEdge, but the specific implementations can override an do something more optimal

Definition at line 87 of file Histogram.h.

References std::vector< T >::begin(), std::vector< T >::end(), std::generate(), and Euclid::Histogram::BinStrategy< VarType >::m_nbins.

Here is the call graph for this function:

Member Data Documentation

◆ m_nbins

template<typename VarType >
size_t Euclid::Histogram::BinStrategy< VarType >::m_nbins
protected

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