All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
#include <Stationarity.h>
Public Member Functions | |
bool | absoluteAtEnd () |
void | add (double newval) |
double | count () |
double | maxErr () |
double | mean () |
int | nextIndex () |
int | oldestIndex () |
bool | relativeAtEnd () |
Stationarity (int queueLength, double ratio=0.001) | |
~Stationarity () |
QGpCoreTools::Stationarity::Stationarity | ( | int | queueLength, |
double | ratio = 0.001 |
||
) |
Absolute criteria (_ratio is used as a threshold)
References TRACE.
{ TRACE; if(_count<_queueLength) return false; if(_count>_imax+_queueLength) { _maxdelta=-1e99; for(int i=0;i<_queueLength;i++) { double delta=fabs(_mean-_values[i]); if(delta>_maxdelta) { _imax=_count-_queueLength+i; _maxdelta=delta; } if(_maxdelta>_ratio) return false; } return true; } else { return _maxdelta<=_ratio; } }
void QGpCoreTools::Stationarity::add | ( | double | newval | ) |
References count(), nextIndex(), oldestIndex(), TRACE, and w.
{ TRACE; if(_count<_queueLength) { _count++; double w=1.0/count(); _mean=_mean*((double)(_count-1)*w)+newval*w; } else { _count++; _mean=_mean+(newval-_values[oldestIndex()])/_queueLength; } _values[nextIndex()]=newval; }
double QGpCoreTools::Stationarity::count | ( | ) | [inline] |
Referenced by add().
{return _count;}
double QGpCoreTools::Stationarity::maxErr | ( | ) | [inline] |
{return _maxdelta;}
double QGpCoreTools::Stationarity::mean | ( | ) | [inline] |
{return _mean;}
int QGpCoreTools::Stationarity::nextIndex | ( | ) | [inline] |
Referenced by add().
{if(_currentI==_queueLength-1) _currentI=-1; return ++_currentI;}
int QGpCoreTools::Stationarity::oldestIndex | ( | ) | [inline] |
Referenced by add().
{if(_currentI==_queueLength-1) return 0; return _currentI+1;}
References TRACE.
{ TRACE; if(_count<_queueLength) return false; if(_count>_imax+_queueLength) { _maxdelta=-1e99; for(int i=0;i<_queueLength;i++) { double delta=fabs(_mean-_values[i]); if(delta>_maxdelta) { _imax=_count-_queueLength+i; _maxdelta=delta; } if(_maxdelta>fabs(_ratio*_mean)) return false; } return true; } else { return _maxdelta<=fabs(_ratio*_mean); } }