VectorStatistics.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #ifdef NOVISUAL
  10. #include <vislearning/nice_nonvis.h>
  11. #else
  12. #include <vislearning/nice.h>
  13. #endif
  14. namespace OBJREC
  15. {
  16. /** @brief online statistics */
  17. class VectorStatistics
  18. {
  19. public:
  20. VectorStatistics(const NICE::Vector &data,bool compute=true);
  21. ~VectorStatistics();
  22. void calculateStatistics();
  23. void initVariables();
  24. void setData(const NICE::Vector &data);
  25. void setMean();
  26. void setMedian();
  27. void setVariance();
  28. void setSkewness();
  29. void setKurtosis();
  30. void setEntropy();
  31. void setNormalizedEntropy();
  32. double getMean();
  33. double getMedian();
  34. double getVariance();
  35. double getStandardDeviation();
  36. double getSkewness();
  37. double getKurtosis();
  38. double getEntropy();
  39. double getNormalizedEntropy();
  40. static double computeEntropy(const NICE::Vector &data);
  41. static double computeNormalizedEntropy(const NICE::Vector &data);
  42. static double computeMean(const NICE::Vector &data);
  43. static double computeMedian(const NICE::Vector &data);
  44. static double computeVariance(const NICE::Vector &data);
  45. static double computeStandardDeviation(const NICE::Vector &data);
  46. static double computeSkew(const NICE::Vector &data);
  47. static double computeKurtosis(const NICE::Vector &data);
  48. private:
  49. NICE::Vector datavector;
  50. double mean, med;
  51. double var, skew, kurt;
  52. double entropy,normalizedentropy;
  53. bool meancalculated, mediancalculated, varcalculated, stdcalculated,
  54. skewcalculated, kurtcalculated,entropycalculated,normalizedentropycalculated;
  55. private:
  56. };
  57. }
  58. #endif