1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- /**
- * @file RunningStat.h
- * @brief B. P. Welford Computation of Mean and Variance download at: http://www.johndcook.com/standard_deviation.html
- * @author Michael Koch
- * @date 18/02/2009
- */
- #ifndef RunningStatINCLUDE
- #define RunningStatINCLUDE
- namespace OBJREC {
- /** @brief online statistics */
- class RunningStat
- {
- public:
- RunningStat() : m_n(0) {}
- /** clear the current statistics */
- void Clear();
-
- /** add a new data element */
- void Push(double x);
-
- /** get number of data elements */
- size_t NumDataValues() const;
- /** get mean value */
- double Mean() const;
-
- /** get variance */
- double Variance() const;
-
- /** get standard deviation */
- double StandardDeviation() const;
-
- private:
- size_t m_n;
- double m_oldM, m_newM, m_oldS, m_newS;
- };
- }
- #endif
|