DGtal  0.9.2
MultiStatistics.h
1 
17 #pragma once
18 
32 #if defined(MultiStatistics_RECURSES)
33 #error Recursive header files inclusion detected in MultiStatistics.h
34 #else // defined(MultiStatistics_RECURSES)
35 
36 #define MultiStatistics_RECURSES
37 
38 #if !defined MultiStatistics_h
39 
40 #define MultiStatistics_h
41 
43 // Inclusions
44 #include <iostream>
45 #include "DGtal/base/Common.h"
47 
48 namespace DGtal
49 {
50 
52 // class MultiStatistics
68 {
69  // ----------------------- Standard services ------------------------------
70 public:
71 
72 
77 
78 
79 
87  MultiStatistics( const unsigned int size, const bool storeSamples = false );
88 
89 
90 
102  static void read( std::istream & in, MultiStatistics & samples,
103  const std::vector<unsigned int> & indices );
104 
105 
106 
107  // ----------------------- Accessors ------------------------------
108  public:
109 
113  inline unsigned int nb() const;
114 
115 
121  inline unsigned int samples( const unsigned int k ) const;
122 
130  inline double mean( const unsigned int k ) const;
131 
139  inline double variance( const unsigned int k ) const;
140 
148  inline double unbiasedVariance( const unsigned int k ) const;
149 
157  inline double max( const unsigned int k ) const;
158 
159 
167  inline unsigned int maxIndice( unsigned int k ) const;
168 
169 
170 
178  inline double min( const unsigned int k ) const;
179 
180 
181 
189  inline unsigned int minIndice(const unsigned int k ) const;
190 
191 
192 
205  inline double value( const unsigned int k, const unsigned int i ) const;
206 
207 
208 
215  void addValue( unsigned int k, double v );
216 
217 
233  template <class Iter>
234  void addValues(const unsigned int k, Iter b, Iter e );
235 
243  void terminate();
244 
245 
257  void init( unsigned int size, bool storeSamples );
258 
259 
264  void clear();
265 
266 
273  void erase();
274 
287  double covariance( const unsigned int x, const unsigned int y,
288  const unsigned int s = 0, unsigned int e = 0 ) const;
289 
300  std::pair<double,double> linearRegression( const unsigned int x,
301  const unsigned int y ) const;
302 
303 
304 
314  double median( const unsigned int k );
315 
316 
317 
318 
319 
320  // ----------------------- Interface --------------------------------------
321 public:
322 
327  void selfDisplay ( std::ostream & out ) const;
328 
333  bool isValid() const;
334 
335  // ------------------------- Protected Datas ------------------------------
336 private:
337 
338  // ------------------------- Private Datas --------------------------------
339 private:
340 
344  unsigned int myNb;
345 
349  unsigned int* mySamples;
350 
355  double* myExp;
356 
361  double* myExp2;
362 
366  double* myVar;
367 
371  double* myUnbiasedVar;
372 
376  double* myMax;
377 
381  unsigned int* myIndiceMax;
382 
386  double* myMin;
387 
391  unsigned int* myIndiceMin;
392 
397 
402  std::vector<double>* myValues;
403 
409 
410  // ------------------------- Hidden services ------------------------------
411 protected:
412 
417  MultiStatistics();
418 
419 private:
420 
426  MultiStatistics ( const MultiStatistics & other );
427 
434  MultiStatistics & operator= ( const MultiStatistics & other );
435 
436  // ------------------------- Internals ------------------------------------
437 private:
438 
439 }; // end of class MultiStatistics
440 
441 
448 std::ostream&
449 operator<< ( std::ostream & out, const MultiStatistics & object );
450 
451 
452 } // namespace DGtal
453 
454 
456 // Includes inline functions.
457 #if !defined(BUILD_INLINE)
458 #include "DGtal/math/MultiStatistics.ih"
459 #endif
460 
461 
462 // //
464 
465 #endif // !defined MultiStatistics_h
466 
467 #undef MultiStatistics_RECURSES
468 #endif // else defined(MultiStatistics_RECURSES)
Aim: This class stores a set of sample values for several variables and can then compute different st...
double value(const unsigned int k, const unsigned int i) const
double variance(const unsigned int k) const
void init(unsigned int size, bool storeSamples)
unsigned int samples(const unsigned int k) const
void addValue(unsigned int k, double v)
unsigned int maxIndice(unsigned int k) const
double max(const unsigned int k) const
double unbiasedVariance(const unsigned int k) const
double covariance(const unsigned int x, const unsigned int y, const unsigned int s=0, unsigned int e=0) const
double mean(const unsigned int k) const
std::vector< double > * myValues
unsigned int * mySamples
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
double median(const unsigned int k)
void selfDisplay(std::ostream &out) const
DGtal is the top-level namespace which contains all DGtal functions and types.
unsigned int minIndice(const unsigned int k) const
unsigned int * myIndiceMin
bool isValid() const
unsigned int * myIndiceMax
static void read(std::istream &in, MultiStatistics &samples, const std::vector< unsigned int > &indices)
double min(const unsigned int k) const
unsigned int nb() const
void addValues(const unsigned int k, Iter b, Iter e)
MultiStatistics & operator=(const MultiStatistics &other)
std::pair< double, double > linearRegression(const unsigned int x, const unsigned int y) const