RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
runningstat.h
Go to the documentation of this file.
1 /*
2  * RunningStat computes running statistics (mean, standard deviation, and
3  * variance) using accurate numerical methods without storing all the numbers.
4  */
5 
6 #include <math.h>
7 
8 class RunningStat
9 {
10 public:
11  RunningStat();
12  ~RunningStat();
13 
14  void clear();
15  void push(double x);
16  int numValues() const;
17  double mean() const;
18  double var() const;
19  double std() const;
20 
21 private:
22  int m_n;
23  double m_oldM, m_newM, m_oldS, m_newS;
24 };
double m_oldS
Definition: runningstat.h:23
void clear()
Definition: runningstat.cpp:15
double m_oldM
Definition: runningstat.h:23
double mean() const
Definition: runningstat.cpp:47
void push(double x)
Definition: runningstat.cpp:21
double std() const
Definition: runningstat.cpp:59
double m_newM
Definition: runningstat.h:23
double m_newS
Definition: runningstat.h:23
int numValues() const
Definition: runningstat.cpp:41
double var() const
Definition: runningstat.cpp:53