RunningStatVector.h 1007 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * @file RunningStatVector.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 19/01/2010
  6. */
  7. #ifndef RunningStatVectorINCLUDE
  8. #define RunningStatVectorINCLUDE
  9. #include "vislearning/baselib/RunningStat.h"
  10. #include <core/vector/VectorT.h>
  11. namespace OBJREC
  12. {
  13. /** @brief online statistics */
  14. class RunningStatVector
  15. {
  16. public:
  17. RunningStatVector(size_t n=0) :
  18. m_n(0),size(n)
  19. {
  20. }
  21. ~RunningStatVector();
  22. /** clear the current statistics */
  23. void Clear();
  24. /** add a new data element */
  25. void Push(NICE::Vector x);
  26. /** get number of data elements */
  27. size_t NumDataValues() const;
  28. /** get vector size */
  29. size_t Size() const;
  30. /** get mean value */
  31. NICE::Vector Mean() const;
  32. /** get variance */
  33. NICE::Vector Variance() const;
  34. /** get standard deviation */
  35. NICE::Vector StandardDeviation() const;
  36. private:
  37. size_t m_n;
  38. size_t size;
  39. std::vector<RunningStat *> datavector;
  40. };
  41. }
  42. #endif