MovingAverage class documentation

Authors

Generated by pauljohn

Software documentation for the MovingAverage class

MovingAverage : SwarmObject

Declared in:
MovingAverage.h

This is a general purpose class for keeping averages. It is called MovingAverage because it was originally intended to keep a moving average from a stream of inputs. The width of the moving average can be any desired integral value.

More generally, this class also can supply the ordinary average, as well as an exponentially weighted moving average of the inputs.


Instance Variables

Method summary

addValue: 

- (void) addValue: (double)x;

Insert a value into the number stream that is contained in this object


drop 

- (void) drop;

Free dynamically allocated memory when this object is destroyed


getAverage 

- (double) getAverage;

Return the average value of all inputs


getEWMA 

- (double) getEWMA;

Return the exponentially weighted moving average


getInputLag: 

- (double) getInputLag: (unsigned int)i;

Return the value that was inputted i periods in the past


getMA 

- (double) getMA;

Return the moving average value


getNumInputs 

- (int) getNumInputs;

Return the number of values that have been inputted


initWidth: 

- (id) initWidth: (int)w;

initialize the moving average object with a width of w


initWidth: Value: 

- (id) initWidth: (int)w Value: (double)val;

Initialize the moving average with a width of interval w and an initial value of val


lispOutDeep: 

- (void) lispOutDeep: (id)stream;

Save the values of all instance variables for serialization purposes




Instance Variables for MovingAverage Class

arrayPosition

@protected unsigned int arrayPosition;

Description forthcoming.


aweight

@protected double aweight;

Description forthcoming.


expWMA

@protected double expWMA;

Description forthcoming.


maInputs

@protected double* maInputs;

Description forthcoming.


numInputs

@protected unsigned int numInputs;

Description forthcoming.


sumOfInputs

@protected double sumOfInputs;

Description forthcoming.


uncorrectedSum

@protected double uncorrectedSum;

Description forthcoming.


width

@protected unsigned int width;

Description forthcoming.