Pol  Revision:3cfda13
clib_utils.cpp
Go to the documentation of this file.
1 
7 #include "clib.h"
8 #include "rawtypes.h"
9 
10 namespace Pol
11 {
12 namespace Clib
13 {
14 OnlineStatistics::OnlineStatistics() : _count( 0 ), _max( 0 ), _mean( 0 ), _m2( 0 ) {}
15 
16 void OnlineStatistics::update( double value )
17 {
18  ++_count;
19  double delta = value - _mean;
20  _mean += delta / _count;
21  _m2 += delta * ( value - _mean );
22  _max = value > _max ? value : _max;
23 }
24 
26 {
27  if ( _count < 2 )
28  return 0;
29  return _m2 / ( _count - 1 );
30 }
31 
32 double OnlineStatistics::mean() const
33 {
34  return _mean;
35 }
37 {
38  return _count;
39 }
40 double OnlineStatistics::max() const
41 {
42  return _max;
43 }
44 }
45 }
void update(double value)
Definition: clib_utils.cpp:16
unsigned long long u64
Definition: rawtypes.h:38
double variance() const
Definition: clib_utils.cpp:25
Definition: berror.cpp:12