Definition at line 28 of file SimpleStats.h.
◆ RunningStat()
RunningStat::RunningStat |
( |
| ) |
|
|
inline |
Definition at line 31 of file SimpleStats.h.
31: m_n(0), m_oldM(0), m_newM(0), m_oldS(0), m_newS(0) {}
◆ Clear()
void RunningStat::Clear |
( |
| ) |
|
|
inline |
◆ Mean()
double RunningStat::Mean |
( |
| ) |
const |
|
inline |
Definition at line 66 of file SimpleStats.h.
67 {
68 return (m_n > 0) ? m_newM : 0.0;
69 }
◆ NumDataValues()
int RunningStat::NumDataValues |
( |
| ) |
const |
|
inline |
◆ Push()
void RunningStat::Push |
( |
double |
x | ) |
|
|
inline |
Definition at line 38 of file SimpleStats.h.
39 {
40 m_n++;
41
42
43 if (m_n == 1)
44 {
45 m_oldM = x;
46 m_oldS = 0.0;
47 m_newM = x;
48 m_newS = 0.0;
49 }
50 else
51 {
52 m_newM = m_oldM + (x - m_oldM)/m_n;
53 m_newS = m_oldS + (x - m_oldM)*(x - m_newM);
54
55
56 m_oldM = m_newM;
57 m_oldS = m_newS;
58 }
59 }
◆ StandardDeviation()
double RunningStat::StandardDeviation |
( |
| ) |
const |
|
inline |
Definition at line 76 of file SimpleStats.h.
77 {
78 return sqrt(Variance());
79 }
◆ Variance()
double RunningStat::Variance |
( |
| ) |
const |
|
inline |
Definition at line 71 of file SimpleStats.h.
72 {
73 return ((m_n > 1) ? m_newS/(m_n - 1) : 0.0);
74 }
The documentation for this class was generated from the following file: