DGtal  1.1.0
Statistic.h
1
17 #pragma once
18
32 #if defined(Statistics_RECURSES)
33 #error Recursive header files inclusion detected in Statistics.h
34 #else // defined(Statistics_RECURSES)
35
36 #define Statistics_RECURSES
37
38 #if !defined Statistics_h
39
40 #define Statistics_h
41
43 // Inclusions
44 #include <iostream>
45 #include "DGtal/base/Common.h"
46 #include "DGtal/kernel/CCommutativeRing.h"
47 #include "DGtal/kernel/NumberTraits.h"
48 #include <utility>
49 #include <vector>
51
52 namespace DGtal
53 {
68  template <typename TQuantity>
69  class Statistic
70  {
71
72  // ----------------------- public types -----------------------------------
73  public:
74  typedef TQuantity Quantity;
76  typedef std::vector< Quantity > Container;
77  typedef typename Container::const_iterator ConstIterator;
78
79  // ----------------------- Standard services ------------------------------
80  public:
81
86
90  Statistic(bool storeSample=false);
91
96  Statistic( const Statistic & other );
97
103  Statistic & operator=( const Statistic & other );
104
112  Statistic & operator+=( const Statistic & other );
113
120  Statistic operator+( const Statistic & other ) const;
121
126
131
132  // ----------------------- Accessors ------------------------------
133  public:
134
135
139  unsigned int samples() const;
140
144  unsigned int size() const;
145
149  double mean() const;
150
154  double variance() const;
155
159  double unbiasedVariance() const;
160
164  Quantity max() const;
165
169  Quantity min() const;
170
171
181
184  Quantity operator[]( unsigned int i ) const;
185
191  void addValue( Quantity v );
192
207  template <class Iter>
208  void addValues( Iter b, Iter e );
209
213  void clear();
214
223  void terminate();
224
225
226
227  // ----------------------- Interface --------------------------------------
228  public:
229
234  void selfDisplay( std::ostream & that_stream ) const;
235
240  bool OK() const;
241
242
243  // ------------------------- Datas ----------------------------------------
244  private:
245
246
247  // ------------------------- Datas ----------------------------------------
248  private:
249
253  unsigned int mySamples;
254
259
265
270
275
276
281
282
288
289
294
295
303
304  };
305
312  template <typename TQuantity>
313  std::ostream&
314  operator<<( std::ostream & thatStream,
315  const Statistic<TQuantity> & that_object_to_display );
316
317
318 } // namespace DGtal
319
320
322 // Includes inline functions/methods if necessary.
323 #include "DGtal/math/Statistic.ih"
324
325 // //
327
328 #endif // !defined Statistic_h
329
330 #undef Statistic_RECURSES
331 #endif // else defined(Statistic_RECURSES)
DGtal::Statistic::myValues
Container myValues
Definition: Statistic.h:287
DGtal::Statistic::myExp2
Quantity myExp2
Definition: Statistic.h:264
DGtal::Statistic::samples
unsigned int samples() const
DGtal::Statistic::begin
ConstIterator begin() const
DGtal::Statistic::Container
std::vector< Quantity > Container
Definition: Statistic.h:76
DGtal::Statistic::max
Quantity max() const
DGtal::concepts::CCommutativeRing
Aim: Defines the mathematical concept equivalent to a unitary commutative ring.
Definition: CCommutativeRing.h:101
DGtal::Statistic::myMax
Quantity myMax
Definition: Statistic.h:269
DGtal::Statistic::myExp
Quantity myExp
Definition: Statistic.h:258
DGtal::Statistic::operator+
Statistic operator+(const Statistic &other) const
DGtal::Statistic::Quantity
TQuantity Quantity
Definition: Statistic.h:74
DGtal::Statistic::~Statistic
~Statistic()
DGtal::Statistic::myIsTerminated
bool myIsTerminated
Definition: Statistic.h:302
DGtal::Statistic
Aim: This class processes a set of sample values for one variable and can then compute different stat...
Definition: Statistic.h:70
DGtal::Statistic::mean
double mean() const
DGtal::Statistic::median
Quantity median()
DGtal::Statistic::end
ConstIterator end() const
DGtal::Statistic::operator=
Statistic & operator=(const Statistic &other)
DGtal::Statistic::min
Quantity min() const
DGtal::Statistic::size
unsigned int size() const
DGtal::Statistic::OK
bool OK() const
DGtal::Statistic::Statistic
Statistic(const Statistic &other)
DGtal::Statistic::unbiasedVariance
double unbiasedVariance() const
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::Statistic::operator+=
Statistic & operator+=(const Statistic &other)
DGtal::Statistic::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CCommutativeRing< Quantity >))
DGtal::Statistic::terminate
void terminate()
DGtal::Statistic::myStoreSamples
bool myStoreSamples
Definition: Statistic.h:293
DGtal::Statistic::myMin
Quantity myMin
Definition: Statistic.h:274
DGtal::Statistic::ConstIterator
Container::const_iterator ConstIterator
Definition: Statistic.h:77
DGtal::Statistic::operator[]
Quantity operator[](unsigned int i) const
DGtal::Statistic::clear
void clear()
DGtal::Statistic::selfDisplay
void selfDisplay(std::ostream &that_stream) const
DGtal::Statistic::myMedian
Quantity myMedian
Definition: Statistic.h:280
DGtal::Statistic::mySamples
unsigned int mySamples
Definition: Statistic.h:253
DGtal::Statistic::Statistic
Statistic(bool storeSample=false)
DGtal::Statistic::variance
double variance() const