VectorStatistics.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * @file VectorStatistics.h
  3. * @brief B. P. Welford Computation of Mean and Variance download at: http://www.johndcook.com/standard_deviation.html
  4. * @author Michael Koch
  5. * @date 18/02/2009
  6. */
  7. #ifndef VectorStatisticsINCLUDE
  8. #define VectorStatisticsINCLUDE
  9. #include "core/vector/VectorT.h"
  10. #include "core/vector/MatrixT.h"
  11. namespace OBJREC
  12. {
  13. /** @brief online statistics */
  14. class VectorStatistics
  15. {
  16. public:
  17. VectorStatistics(const NICE::Vector &data,bool compute=true);
  18. ~VectorStatistics();
  19. void calculateStatistics();
  20. void initVariables();
  21. void setData(const NICE::Vector &data);
  22. void setMean();
  23. void setMedian();
  24. void setVariance();
  25. void setSkewness();
  26. void setKurtosis();
  27. void setEntropy();
  28. void setNormalizedEntropy();
  29. double getMean();
  30. double getMedian();
  31. double getVariance();
  32. double getStandardDeviation();
  33. double getSkewness();
  34. double getKurtosis();
  35. double getEntropy();
  36. double getNormalizedEntropy();
  37. static double computeEntropy(const NICE::Vector &data);
  38. static double computeNormalizedEntropy(const NICE::Vector &data);
  39. static double computeMean(const NICE::Vector &data);
  40. static double computeMedian(const NICE::Vector &data);
  41. static double computeVariance(const NICE::Vector &data);
  42. static double computeStandardDeviation(const NICE::Vector &data);
  43. static double computeSkew(const NICE::Vector &data);
  44. static double computeKurtosis(const NICE::Vector &data);
  45. private:
  46. NICE::Vector datavector;
  47. double mean, med;
  48. double var, skew, kurt;
  49. double entropy,normalizedentropy;
  50. bool meancalculated, mediancalculated, varcalculated, stdcalculated,
  51. skewcalculated, kurtcalculated,entropycalculated,normalizedentropycalculated;
  52. private:
  53. };
  54. }
  55. #endif