All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions
QGpCoreTools::Stationarity Class Reference

#include <Stationarity.h>

List of all members.

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 ()

Constructor & Destructor Documentation

QGpCoreTools::Stationarity::Stationarity ( int  queueLength,
double  ratio = 0.001 
)

Sets queue length for stationarity window

References TRACE.

{
  TRACE;
  _queueLength=queueLength;
  _mean=0;
  _currentI=-1;
  _values=new double [_queueLength];
  _count=0;
  _imax=0;
  _maxdelta=1e99;
  _ratio=ratio;
}

References TRACE.

{
  TRACE;
  delete [] _values;
}

Member Function Documentation

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;}
{return _maxdelta;}
double QGpCoreTools::Stationarity::mean ( ) [inline]
{return _mean;}

Referenced by add().

{if(_currentI==_queueLength-1) _currentI=-1; return ++_currentI;}

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);
  }
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines