DGtal  1.1.0
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
67 {
68  // ----------------------- Standard services ------------------------------
69 public:
70 
71 
76 
77 
78 
86  MultiStatistics( const unsigned int size, const bool storeSamples = false );
87 
88 
89 
101  static void read( std::istream & in, MultiStatistics & samples,
102  const std::vector<unsigned int> & indices );
103 
104 
105 
106  // ----------------------- Accessors ------------------------------
107  public:
108 
112  inline unsigned int nb() const;
113 
114 
120  inline unsigned int samples( const unsigned int k ) const;
121 
129  inline double mean( const unsigned int k ) const;
130 
138  inline double variance( const unsigned int k ) const;
139 
147  inline double unbiasedVariance( const unsigned int k ) const;
148 
156  inline double max( const unsigned int k ) const;
157 
158 
166  inline unsigned int maxIndice( unsigned int k ) const;
167 
168 
169 
177  inline double min( const unsigned int k ) const;
178 
179 
180 
188  inline unsigned int minIndice(const unsigned int k ) const;
189 
190 
191 
204  inline double value( const unsigned int k, const unsigned int i ) const;
205 
206 
207 
214  void addValue( unsigned int k, double v );
215 
216 
232  template <class Iter>
233  void addValues(const unsigned int k, Iter b, Iter e );
234 
242  void terminate();
243 
244 
256  void init( unsigned int size, bool storeSamples );
257 
258 
263  void clear();
264 
265 
272  void erase();
273 
286  double covariance( const unsigned int x, const unsigned int y,
287  const unsigned int s = 0, unsigned int e = 0 ) const;
288 
299  std::pair<double,double> linearRegression( const unsigned int x,
300  const unsigned int y ) const;
301 
302 
303 
313  double median( const unsigned int k );
314 
315 
316 
317 
318 
319  // ----------------------- Interface --------------------------------------
320 public:
321 
326  void selfDisplay ( std::ostream & out ) const;
327 
332  bool isValid() const;
333 
334  // ------------------------- Protected Datas ------------------------------
335 private:
336 
337  // ------------------------- Private Datas --------------------------------
338 private:
339 
343  unsigned int myNb;
344 
348  unsigned int* mySamples;
349 
354  double* myExp;
355 
360  double* myExp2;
361 
365  double* myVar;
366 
370  double* myUnbiasedVar;
371 
375  double* myMax;
376 
380  unsigned int* myIndiceMax;
381 
385  double* myMin;
386 
390  unsigned int* myIndiceMin;
391 
396 
401  std::vector<double>* myValues;
402 
408 
409  // ------------------------- Hidden services ------------------------------
410 protected:
411 
417 
418 private:
419 
425  MultiStatistics ( const MultiStatistics & other );
426 
434 
435  // ------------------------- Internals ------------------------------------
436 private:
437 
438 }; // end of class MultiStatistics
439 
440 
447 std::ostream&
448 operator<< ( std::ostream & out, const MultiStatistics & object );
449 
450 
451 } // namespace DGtal
452 
453 
455 // Includes inline functions.
456 #if !defined(BUILD_INLINE)
457 #include "DGtal/math/MultiStatistics.ih"
458 #endif
459 
460 
461 // //
463 
464 #endif // !defined MultiStatistics_h
465 
466 #undef MultiStatistics_RECURSES
467 #endif // else defined(MultiStatistics_RECURSES)
DGtal::MultiStatistics::myVar
double * myVar
Definition: MultiStatistics.h:365
DGtal::MultiStatistics::addValues
void addValues(const unsigned int k, Iter b, Iter e)
DGtal::MultiStatistics::myIsTerminate
bool myIsTerminate
Definition: MultiStatistics.h:407
DGtal::MultiStatistics::myMin
double * myMin
Definition: MultiStatistics.h:385
DGtal::MultiStatistics::myValues
std::vector< double > * myValues
Definition: MultiStatistics.h:401
DGtal::MultiStatistics::myMax
double * myMax
Definition: MultiStatistics.h:375
DGtal::MultiStatistics::nb
unsigned int nb() const
DGtal::MultiStatistics::minIndice
unsigned int minIndice(const unsigned int k) const
DGtal::MultiStatistics::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::MultiStatistics::myExp
double * myExp
Definition: MultiStatistics.h:354
DGtal::MultiStatistics::~MultiStatistics
~MultiStatistics()
DGtal::MultiStatistics::myNb
unsigned int myNb
Definition: MultiStatistics.h:343
DGtal::MultiStatistics::myIndiceMin
unsigned int * myIndiceMin
Definition: MultiStatistics.h:390
DGtal::MultiStatistics::variance
double variance(const unsigned int k) const
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::MultiStatistics::myIndiceMax
unsigned int * myIndiceMax
Definition: MultiStatistics.h:380
DGtal::MultiStatistics::median
double median(const unsigned int k)
DGtal::MultiStatistics::maxIndice
unsigned int maxIndice(unsigned int k) const
DGtal::MultiStatistics::mySamples
unsigned int * mySamples
Definition: MultiStatistics.h:348
DGtal::MultiStatistics::erase
void erase()
DGtal::MultiStatistics::MultiStatistics
MultiStatistics()
DGtal::MultiStatistics::operator=
MultiStatistics & operator=(const MultiStatistics &other)
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::MultiStatistics::linearRegression
std::pair< double, double > linearRegression(const unsigned int x, const unsigned int y) const
DGtal::MultiStatistics::max
double max(const unsigned int k) const
DGtal::MultiStatistics::unbiasedVariance
double unbiasedVariance(const unsigned int k) const
DGtal::MultiStatistics::isValid
bool isValid() const
DGtal::MultiStatistics::clear
void clear()
DGtal::MultiStatistics::MultiStatistics
MultiStatistics(const MultiStatistics &other)
DGtal::MultiStatistics::MultiStatistics
MultiStatistics(const unsigned int size, const bool storeSamples=false)
DGtal::MultiStatistics::terminate
void terminate()
DGtal::MultiStatistics::mean
double mean(const unsigned int k) const
DGtal::MultiStatistics::value
double value(const unsigned int k, const unsigned int i) const
DGtal::MultiStatistics
Aim: This class stores a set of sample values for several variables and can then compute different st...
Definition: MultiStatistics.h:67
DGtal::MultiStatistics::addValue
void addValue(unsigned int k, double v)
DGtal::MultiStatistics::read
static void read(std::istream &in, MultiStatistics &samples, const std::vector< unsigned int > &indices)
DGtal::MultiStatistics::myExp2
double * myExp2
Definition: MultiStatistics.h:360
DGtal::MultiStatistics::myStoreSamples
bool myStoreSamples
Definition: MultiStatistics.h:395
DGtal::MultiStatistics::samples
unsigned int samples(const unsigned int k) const
DGtal::MultiStatistics::init
void init(unsigned int size, bool storeSamples)
DGtal::MultiStatistics::covariance
double covariance(const unsigned int x, const unsigned int y, const unsigned int s=0, unsigned int e=0) const
DGtal::MultiStatistics::min
double min(const unsigned int k) const
DGtal::MultiStatistics::myUnbiasedVar
double * myUnbiasedVar
Definition: MultiStatistics.h:370