DGtal 1.3.0
|
Aim: Represents a typical histogram in statistics, which is a discrete estimate of the probability distribution of a continuous variable. More...
#include <DGtal/math/Histogram.h>
Public Types | |
enum | Formula { SquareRoot , Sturges , Rice , Scott } |
typedef TQuantity | Quantity |
typedef TBinner | Binner |
typedef Histogram< Quantity, Binner > | Self |
typedef Binner::Bin | Bin |
typedef DGtal::uint64_t | Size |
typedef std::vector< Size > | Container |
typedef Container::const_iterator | ConstIterator |
Public Member Functions | |
BOOST_CONCEPT_ASSERT ((concepts::CEuclideanRing< TQuantity >)) | |
BOOST_CONCEPT_ASSERT ((concepts::CBinner< TBinner >)) | |
BOOST_STATIC_ASSERT ((boost::is_same< TQuantity, typename TBinner::Quantity >::value)) | |
~Histogram () | |
Histogram () | |
void | clear () |
void | init (Clone< Binner > binner) |
void | init (Formula formula, const Statistic< Quantity > &stat) |
void | init (Bin nbBins, const Statistic< Quantity > &stat) |
void | addValue (Quantity q) |
template<typename TInputIterator > | |
void | addValues (TInputIterator it, TInputIterator itE) |
void | terminate () |
Bin | bin (Quantity q) const |
Bin | size () const |
Size | area () const |
Size | nb (Bin b) const |
Size | accumulation (Bin b) const |
double | pdf (Bin b) const |
double | cdf (Bin b) const |
void | selfDisplay (std::ostream &out) const |
bool | isValid () const |
Protected Attributes | |
const Binner * | myBinner |
The binner that places quantities into a bin. More... | |
Container | myHistogram |
The histogram data. More... | |
Container | myCumulativeHistogram |
The cumulative histogram data. More... | |
Private Member Functions | |
Histogram (const Histogram &other) | |
Histogram & | operator= (const Histogram &other) |
void | prepare (Bin size) |
Aim: Represents a typical histogram in statistics, which is a discrete estimate of the probability distribution of a continuous variable.
Description of template class 'Histogram'
TQuantity | any model of CEuclideanRing listed in NumberTraits and that can be castToDouble. |
TBinner | any model of CBinner that puts a quantity into a bin. Default is RegularBinner<TQuantity>. |
Definition at line 145 of file Histogram.h.
typedef Binner::Bin DGtal::Histogram< TQuantity, TBinner >::Bin |
Definition at line 157 of file Histogram.h.
typedef TBinner DGtal::Histogram< TQuantity, TBinner >::Binner |
Definition at line 155 of file Histogram.h.
typedef Container::const_iterator DGtal::Histogram< TQuantity, TBinner >::ConstIterator |
Definition at line 160 of file Histogram.h.
typedef std::vector<Size> DGtal::Histogram< TQuantity, TBinner >::Container |
Definition at line 159 of file Histogram.h.
typedef TQuantity DGtal::Histogram< TQuantity, TBinner >::Quantity |
Definition at line 154 of file Histogram.h.
typedef Histogram< Quantity, Binner > DGtal::Histogram< TQuantity, TBinner >::Self |
Definition at line 156 of file Histogram.h.
typedef DGtal::uint64_t DGtal::Histogram< TQuantity, TBinner >::Size |
Definition at line 158 of file Histogram.h.
enum DGtal::Histogram::Formula |
Determines the number of bins k or the width h as a function of n (number of samples), s (variance of samples).
Enumerator | |
---|---|
SquareRoot | Rule is k=sqrt(n) |
Sturges | Rule is k=ceil(log_2(n)+1) |
Rice | Rule is k=ceil(n^(1/3)) |
Scott | Rule is h=3.5s/(n^(1/3)) |
Definition at line 166 of file Histogram.h.
DGtal::Histogram< TQuantity, TBinner >::~Histogram | ( | ) |
Destructor.
DGtal::Histogram< TQuantity, TBinner >::Histogram | ( | ) |
Constructor. The object is not valid.
|
private |
Copy constructor.
other | the object to clone. Forbidden by default. |
Size DGtal::Histogram< TQuantity, TBinner >::accumulation | ( | Bin | b | ) | const |
b | any bin in 0 .. size()-1 |
void DGtal::Histogram< TQuantity, TBinner >::addValue | ( | Quantity | q | ) |
Add the quantity q to the histogram.
q | any quantity. |
void DGtal::Histogram< TQuantity, TBinner >::addValues | ( | TInputIterator | it, |
TInputIterator | itE | ||
) |
Add the quantities stored in range [it,itE) to the histogram.
TInputIterator | any model of boost::InputIterator on Quantity. |
it | an iterator on the first element of the range [it,itE) |
itE | an iterator after the last element of the range [it,itE) |
Referenced by testHistogramGaussian(), testHistogramGaussian2(), and testHistogramUniform().
Size DGtal::Histogram< TQuantity, TBinner >::area | ( | ) | const |
Bin DGtal::Histogram< TQuantity, TBinner >::bin | ( | Quantity | q | ) | const |
q | any quantity |
DGtal::Histogram< TQuantity, TBinner >::BOOST_CONCEPT_ASSERT | ( | (concepts::CBinner< TBinner >) | ) |
DGtal::Histogram< TQuantity, TBinner >::BOOST_CONCEPT_ASSERT | ( | (concepts::CEuclideanRing< TQuantity >) | ) |
DGtal::Histogram< TQuantity, TBinner >::BOOST_STATIC_ASSERT | ( | (boost::is_same< TQuantity, typename TBinner::Quantity >::value) | ) |
double DGtal::Histogram< TQuantity, TBinner >::cdf | ( | Bin | b | ) | const |
Referenced by testHistogramGaussian(), testHistogramGaussian2(), and testHistogramUniform().
void DGtal::Histogram< TQuantity, TBinner >::clear | ( | ) |
The object is fully cleared. The object must be initialized in order to be valid.
void DGtal::Histogram< TQuantity, TBinner >::init | ( | Bin | nbBins, |
const Statistic< Quantity > & | stat | ||
) |
Initialization from a number of bins and a statistic (min, max, samples, variance can typically be used).
void DGtal::Histogram< TQuantity, TBinner >::init | ( | Clone< Binner > | binner | ) |
Initialization from Binner. The binner is cloned into this object.
Referenced by testHistogramGaussian(), testHistogramGaussian2(), and testHistogramUniform().
void DGtal::Histogram< TQuantity, TBinner >::init | ( | Formula | formula, |
const Statistic< Quantity > & | stat | ||
) |
Initialization from a statistic (min, max, samples, variance can typically be used) and a given formula.
bool DGtal::Histogram< TQuantity, TBinner >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
Size DGtal::Histogram< TQuantity, TBinner >::nb | ( | Bin | b | ) | const |
b | any bin in 0 .. size()-1 |
|
private |
Assignment.
other | the object to copy. |
double DGtal::Histogram< TQuantity, TBinner >::pdf | ( | Bin | b | ) | const |
Referenced by testHistogramGaussian(), testHistogramGaussian2(), and testHistogramUniform().
|
private |
Prepares container for further data.
void DGtal::Histogram< TQuantity, TBinner >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
Bin DGtal::Histogram< TQuantity, TBinner >::size | ( | ) | const |
Referenced by testHistogramGaussian(), testHistogramGaussian2(), and testHistogramUniform().
void DGtal::Histogram< TQuantity, TBinner >::terminate | ( | ) |
Should be called when all values have been added.
Referenced by testHistogramGaussian(), testHistogramGaussian2(), and testHistogramUniform().
|
protected |
The binner that places quantities into a bin.
Definition at line 285 of file Histogram.h.
|
protected |
The cumulative histogram data.
Definition at line 289 of file Histogram.h.
|
protected |
The histogram data.
Definition at line 287 of file Histogram.h.