DGtal  1.4.2
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)
36 #define Statistics_RECURSES
37 
38 #if !defined Statistics_h
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)
Aim: This class processes a set of sample values for one variable and can then compute different stat...
Definition: Statistic.h:70
Quantity myMax
Definition: Statistic.h:269
ConstIterator end() const
TQuantity Quantity
Definition: Statistic.h:74
Container::const_iterator ConstIterator
Definition: Statistic.h:77
Statistic operator+(const Statistic &other) const
bool OK() const
double variance() const
Quantity myExp2
Definition: Statistic.h:264
Quantity myExp
Definition: Statistic.h:258
Quantity median()
unsigned int size() const
unsigned int samples() const
Quantity myMedian
Definition: Statistic.h:280
ConstIterator begin() const
double mean() const
Container myValues
Definition: Statistic.h:287
Statistic(bool storeSample=false)
Statistic & operator=(const Statistic &other)
Statistic(const Statistic &other)
BOOST_CONCEPT_ASSERT((concepts::CCommutativeRing< Quantity >))
Quantity myMin
Definition: Statistic.h:274
double unbiasedVariance() const
unsigned int mySamples
Definition: Statistic.h:253
Quantity max() const
std::vector< Quantity > Container
Definition: Statistic.h:76
Quantity operator[](unsigned int i) const
void selfDisplay(std::ostream &that_stream) const
Statistic & operator+=(const Statistic &other)
void addValues(Iter b, Iter e)
Quantity min() const
void addValue(Quantity v)
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
Aim: Defines the mathematical concept equivalent to a unitary commutative ring.