OpenMS  2.7.0
Public Types | List of all members
Histogram< ValueType, BinSizeType > Class Template Reference

Representation of a histogram. More...

#include <OpenMS/MATH/STATISTICS/Histogram.h>

Collaboration diagram for Histogram< ValueType, BinSizeType >:
[legend]

Public Types

typedef std::vector< ValueType >::const_iterator ConstIterator
 Non-mutable iterator of the bins. More...
 

Public Member Functions

Assignment and equality operators
bool operator== (const Histogram &histogram) const
 Equality operator. More...
 
bool operator!= (const Histogram &histogram) const
 Inequality operator. More...
 
Histogramoperator= (const Histogram &histogram)
 Assignment. More...
 

Iterators

BinSizeType min_
 Lower bound. More...
 
BinSizeType max_
 Upper bound. More...
 
BinSizeType bin_size_
 Bin size. More...
 
std::vector< ValueType > bins_
 Vector of bins. More...
 
ConstIterator begin () const
 Non-mutable iterator pointing to the first bin. More...
 
ConstIterator end () const
 Non-mutable iterator pointing after the last bin. More...
 
void applyLogTransformation (BinSizeType multiplier)
 Transforms the bin values with f(x)=multiplier*log(x+1) More...
 
Size valueToBin (BinSizeType val) const
 Returns the bin index a given value belongs to. More...
 
void initBins_ ()
 initialize the bins More...
 

Constructors and Destructors

 Histogram ()
 default constructor More...
 
 Histogram (const Histogram &histogram)
 copy constructor More...
 
 Histogram (BinSizeType min, BinSizeType max, BinSizeType bin_size)
 constructor with min, max (inclusive) and bin width More...
 
template<typename DataIterator >
 Histogram (DataIterator begin, DataIterator end, BinSizeType min, BinSizeType max, BinSizeType bin_size)
 constructor with data iterator and min, max, bin_size parameters More...
 
virtual ~Histogram ()
 destructor More...
 
BinSizeType minBound () const
 returns the lower bound (inclusive) More...
 
BinSizeType maxBound () const
 returns the upper bound (inclusive) More...
 
ValueType maxValue () const
 returns the bin with the highest count More...
 
ValueType minValue () const
 returns the bin with lowest count More...
 
BinSizeType binSize () const
 returns the bin size More...
 
Size size () const
 returns the number of bins More...
 
ValueType operator[] (Size index) const
 returns the value of bin index More...
 
BinSizeType centerOfBin (Size bin_index) const
 returns the center position of the bin with the index bin_index More...
 
BinSizeType rightBorderOfBin (Size bin_index) const
 returns the first value to the right side of the bin with the index bin_index, which is not part of this bin, i.e. open right side of the interval. More...
 
BinSizeType leftBorderOfBin (Size bin_index) const
 returns the leftmost value of the bin with the index bin_index, which is part of this bin, i.e. closed left side of the interval. More...
 
ValueType binValue (BinSizeType val) const
 returns the value of bin corresponding to the value val More...
 
Size inc (BinSizeType val, ValueType increment=1)
 increases the bin corresponding to value val by increment More...
 
Size incUntil (BinSizeType val, bool inclusive, ValueType increment=1)
 
Size incFrom (BinSizeType val, bool inclusive, ValueType increment=1)
 
void reset (BinSizeType min, BinSizeType max, BinSizeType bin_size)
 resets the histogram with the given range and bin size More...
 
template<typename DataIterator >
static void getCumulativeHistogram (DataIterator begin, DataIterator end, bool complement, bool inclusive, Histogram< ValueType, BinSizeType > &histogram)
 

Detailed Description

template<typename ValueType = UInt, typename BinSizeType = double>
class OpenMS::Math::Histogram< ValueType, BinSizeType >

Representation of a histogram.

The first template argument gives the Type of the values that are stored in the bins. The second argument gives the type for the bin size and range.

Member Typedef Documentation

◆ ConstIterator

typedef std::vector<ValueType>::const_iterator ConstIterator

Non-mutable iterator of the bins.

Constructor & Destructor Documentation

◆ Histogram() [1/4]

Histogram ( )
inline

default constructor

◆ Histogram() [2/4]

Histogram ( const Histogram< ValueType, BinSizeType > &  histogram)
inline

copy constructor

◆ Histogram() [3/4]

Histogram ( BinSizeType  min,
BinSizeType  max,
BinSizeType  bin_size 
)
inline

constructor with min, max (inclusive) and bin width

Exceptions
Exception::OutOfRangeis thrown if bin_size negative or zero

References Histogram< ValueType, BinSizeType >::initBins_().

◆ Histogram() [4/4]

Histogram ( DataIterator  begin,
DataIterator  end,
BinSizeType  min,
BinSizeType  max,
BinSizeType  bin_size 
)
inline

constructor with data iterator and min, max, bin_size parameters

Exceptions
Exception::OutOfRangeis thrown if bin_size negative or zero

References Histogram< ValueType, BinSizeType >::begin(), Histogram< ValueType, BinSizeType >::end(), Histogram< ValueType, BinSizeType >::inc(), and Histogram< ValueType, BinSizeType >::initBins_().

◆ ~Histogram()

virtual ~Histogram ( )
inlinevirtual

destructor

Member Function Documentation

◆ applyLogTransformation()

void applyLogTransformation ( BinSizeType  multiplier)
inline

Transforms the bin values with f(x)=multiplier*log(x+1)

References Histogram< ValueType, BinSizeType >::bins_.

◆ begin()

ConstIterator begin ( ) const
inline

◆ binSize()

BinSizeType binSize ( ) const
inline

returns the bin size

References Histogram< ValueType, BinSizeType >::bin_size_.

◆ binValue()

ValueType binValue ( BinSizeType  val) const
inline

returns the value of bin corresponding to the value val

Exceptions
Exception::OutOfRangeis thrown if the value is out of valid range

References Histogram< ValueType, BinSizeType >::bins_, and Histogram< ValueType, BinSizeType >::valueToBin().

◆ centerOfBin()

BinSizeType centerOfBin ( Size  bin_index) const
inline

returns the center position of the bin with the index bin_index

Exceptions
Exception::IndexOverflowis thrown for invalid indices

References Histogram< ValueType, BinSizeType >::bin_size_, Histogram< ValueType, BinSizeType >::bins_, and Histogram< ValueType, BinSizeType >::min_.

Referenced by OpenMS::Math::operator<<().

◆ end()

ConstIterator end ( ) const
inline

◆ getCumulativeHistogram()

static void getCumulativeHistogram ( DataIterator  begin,
DataIterator  end,
bool  complement,
bool  inclusive,
Histogram< ValueType, BinSizeType > &  histogram 
)
inlinestatic

◆ inc()

Size inc ( BinSizeType  val,
ValueType  increment = 1 
)
inline

increases the bin corresponding to value val by increment

Returns
The index of the increased bin.
Exceptions
Exception::OutOfRangeis thrown if the value is out of valid range

References Histogram< ValueType, BinSizeType >::bins_, and Histogram< ValueType, BinSizeType >::valueToBin().

Referenced by Histogram< ValueType, BinSizeType >::Histogram().

◆ incFrom()

Size incFrom ( BinSizeType  val,
bool  inclusive,
ValueType  increment = 1 
)
inline

◆ incUntil()

Size incUntil ( BinSizeType  val,
bool  inclusive,
ValueType  increment = 1 
)
inline

◆ initBins_()

void initBins_ ( )
inlineprotected

◆ leftBorderOfBin()

BinSizeType leftBorderOfBin ( Size  bin_index) const
inline

returns the leftmost value of the bin with the index bin_index, which is part of this bin, i.e. closed left side of the interval.

Exceptions
Exception::IndexOverflowis thrown for invalid indices

References Histogram< ValueType, BinSizeType >::bin_size_, Histogram< ValueType, BinSizeType >::bins_, and Histogram< ValueType, BinSizeType >::min_.

◆ maxBound()

BinSizeType maxBound ( ) const
inline

returns the upper bound (inclusive)

References Histogram< ValueType, BinSizeType >::max_.

Referenced by Histogram< ValueType, BinSizeType >::rightBorderOfBin().

◆ maxValue()

ValueType maxValue ( ) const
inline

returns the bin with the highest count

References Histogram< ValueType, BinSizeType >::bins_.

◆ minBound()

BinSizeType minBound ( ) const
inline

returns the lower bound (inclusive)

References Histogram< ValueType, BinSizeType >::min_.

◆ minValue()

ValueType minValue ( ) const
inline

returns the bin with lowest count

References Histogram< ValueType, BinSizeType >::bins_.

◆ operator!=()

bool operator!= ( const Histogram< ValueType, BinSizeType > &  histogram) const
inline

Inequality operator.

References Histogram< ValueType, BinSizeType >::operator==().

◆ operator=()

Histogram& operator= ( const Histogram< ValueType, BinSizeType > &  histogram)
inline

◆ operator==()

bool operator== ( const Histogram< ValueType, BinSizeType > &  histogram) const
inline

◆ operator[]()

ValueType operator[] ( Size  index) const
inline

returns the value of bin index

Exceptions
Exception::IndexOverflowis thrown for invalid indices

References Histogram< ValueType, BinSizeType >::bins_.

◆ reset()

void reset ( BinSizeType  min,
BinSizeType  max,
BinSizeType  bin_size 
)
inline

resets the histogram with the given range and bin size

Exceptions
Exception::OutOfRangeis thrown if bin_size negative or zero

References Histogram< ValueType, BinSizeType >::bin_size_, Histogram< ValueType, BinSizeType >::bins_, Histogram< ValueType, BinSizeType >::max_, and Histogram< ValueType, BinSizeType >::min_.

◆ rightBorderOfBin()

BinSizeType rightBorderOfBin ( Size  bin_index) const
inline

returns the first value to the right side of the bin with the index bin_index, which is not part of this bin, i.e. open right side of the interval.

Exceptions
Exception::IndexOverflowis thrown for invalid indices

References Histogram< ValueType, BinSizeType >::bin_size_, Histogram< ValueType, BinSizeType >::bins_, Histogram< ValueType, BinSizeType >::maxBound(), and Histogram< ValueType, BinSizeType >::min_.

◆ size()

Size size ( ) const
inline

returns the number of bins

References Histogram< ValueType, BinSizeType >::bins_.

Referenced by OpenMS::Math::operator<<().

◆ valueToBin()

Size valueToBin ( BinSizeType  val) const
inline

Member Data Documentation

◆ bin_size_

BinSizeType bin_size_
protected

◆ bins_

std::vector<ValueType> bins_
protected

◆ max_

BinSizeType max_
protected

◆ min_

BinSizeType min_
protected