| OpenMS 2.5.0

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Histogram< ValueType, BinSizeType > Class Template Reference
Math

Representation of a histogram. More...

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

## Public Types

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

## Public Member Functions

BinSizeType | minBound () const
| returns the lower bound More...
BinSizeType | maxBound () const
| returns the upper bound More...
ValueType | maxValue () const
| returns the highest value of all bins More...
ValueType | minValue () const
| returns the lowest value of all bins 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...
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...
void | applyLogTransformation (BinSizeType multiplier)
| Transforms the bin values with f(x)=multiplier*log(x+1) 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 and bin size 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...
Assignment and equality operators
bool | operator== (const Histogram &histogram) const
| Equality operator. More...
bool | operator!= (const Histogram &histogram) const
| Inequality operator. More...
Histogram & | operator= (const Histogram &histogram)
| Assignment. More...
Iterators
ConstIterator | begin () const
| Non-mutable iterator pointing to the first bin. More...
ConstIterator | end () const
| Non-mutable iterator pointing after the last bin. More...

## Static Public Member Functions

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

## Protected Member Functions

Size | valToBin_ (BinSizeType val) const
| Returns the bin a given value belongs to. More...
void | initBins_ ()
| initialize the bins More...

## Protected Attributes

BinSizeType | min_
| Lower bound. More...
BinSizeType | max_
| Upper bound. More...
BinSizeType | bin_size_
| Bin size. More...
std::vector< ValueType > | bins_
| Vector of bins. More...

## 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 and bin size

Exceptions

  Exception::OutOfRange | is 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::OutOfRange | is 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 | ( |  | ) |

inline virtual

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

Non-mutable iterator pointing to the first bin.

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

## ◆ 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::OutOfRange | is thrown if the value is out of valid range

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

## ◆ centerOfBin()

BinSizeType centerOfBin | ( | Size | bin_index | ) | const

inline

returns the center position of the bin with the index `bin_index`

Exceptions

  Exception::IndexOverflow | is thrown for invalid indices

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

## ◆ end()

ConstIterator end | ( |  | ) | const

inline

Non-mutable iterator pointing after the last bin.

References Histogram< ValueType, BinSizeType >::bins_.

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

## ◆ getCumulativeHistogram()

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

inline static

References Histogram< ValueType, BinSizeType >::begin(), Histogram< ValueType, BinSizeType >::end(), Histogram< ValueType, BinSizeType >::incFrom(), and Histogram< ValueType, BinSizeType >::incUntil().

## ◆ 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::OutOfRange | is thrown if the value is out of valid range

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

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

## ◆ incFrom()

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

inline

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

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

## ◆ incUntil()

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

inline

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

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

## ◆ initBins_()

void initBins_ | ( |  | ) |

inline protected

initialize the bins

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

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

## ◆ maxBound()

BinSizeType maxBound | ( |  | ) | const

inline

returns the upper bound

References Histogram< ValueType, BinSizeType >::max_.

## ◆ maxValue()

ValueType maxValue | ( |  | ) | const

inline

returns the highest value of all bins

References Histogram< ValueType, BinSizeType >::bins_.

## ◆ minBound()

BinSizeType minBound | ( |  | ) | const

inline

returns the lower bound

References Histogram< ValueType, BinSizeType >::min_.

## ◆ minValue()

ValueType minValue | ( |  | ) | const

inline

returns the lowest value of all bins

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

Assignment.

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

## ◆ operator==()

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

inline

Equality operator.

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

## ◆ operator[]()

ValueType operator[] | ( | Size | index | ) | const

inline

returns the value of bin `index`

Exceptions

  Exception::IndexOverflow | is 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::OutOfRange | is 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_.

## ◆ size()

Size size | ( |  | ) | const

inline

returns the number of bins

References Histogram< ValueType, BinSizeType >::bins_.

## ◆ valToBin_()

Size valToBin_ | ( | BinSizeType | val | ) | const

inline protected

Returns the bin a given value belongs to.

Exceptions

  Exception::OutOfRange | is thrown if the value is out of valid range

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

Referenced by Histogram< ValueType, BinSizeType >::binValue(), Histogram< ValueType, BinSizeType >::inc(), Histogram< ValueType, BinSizeType >::incFrom(), and Histogram< ValueType, BinSizeType >::incUntil().

## Member Data Documentation

## ◆ bin_size_

BinSizeType bin_size_

protected

Bin size.

Referenced by Histogram< ValueType, BinSizeType >::binSize(), Histogram< ValueType, BinSizeType >::centerOfBin(), Histogram< ValueType, BinSizeType >::initBins_(), Histogram< ValueType, BinSizeType >::operator=(), and Histogram< ValueType, BinSizeType >::reset().

## ◆ bins_

std::vector<ValueType> bins_

protected

Vector of bins.

Referenced by Histogram< ValueType, BinSizeType >::applyLogTransformation(), Histogram< ValueType, BinSizeType >::binValue(), Histogram< ValueType, BinSizeType >::centerOfBin(), Histogram< ValueType, BinSizeType >::end(), Histogram< ValueType, BinSizeType >::inc(), Histogram< ValueType, BinSizeType >::incFrom(), Histogram< ValueType, BinSizeType >::incUntil(), Histogram< ValueType, BinSizeType >::maxValue(), Histogram< ValueType, BinSizeType >::minValue(), Histogram< ValueType, BinSizeType >::operator=(), Histogram< ValueType, BinSizeType >::operator[](), Histogram< ValueType, BinSizeType >::reset(), Histogram< ValueType, BinSizeType >::size(), and Histogram< ValueType, BinSizeType >::valToBin_().

## ◆ max_

BinSizeType max_

protected

Upper bound.

Referenced by Histogram< ValueType, BinSizeType >::initBins_(), Histogram< ValueType, BinSizeType >::maxBound(), Histogram< ValueType, BinSizeType >::operator=(), Histogram< ValueType, BinSizeType >::reset(), and Histogram< ValueType, BinSizeType >::valToBin_().

## ◆ min_

BinSizeType min_

protected

Lower bound.

Referenced by Histogram< ValueType, BinSizeType >::centerOfBin(), Histogram< ValueType, BinSizeType >::initBins_(), Histogram< ValueType, BinSizeType >::minBound(), Histogram< ValueType, BinSizeType >::operator=(), Histogram< ValueType, BinSizeType >::reset(), and Histogram< ValueType, BinSizeType >::valToBin_().