MovingAverage


Inherits From:
SwarmObject
Declared In:
MovingAverage.h


Class Description

This is a general purpose class for creating Moving Averages, either flat "equally weighted" moving averages or exponentially weighted moving averages


Instance Variables

int width;
int numInputs;
double *maInputs;
int arrayPosition;
double sumOfInputs;
double uncorrectedSum;
double expWMA;
double aweight, bweight;

widthnumber of observations used for a fixed interval moving average
numInputsnumber of observations that have already been inserted
maInputshistorical inputs are kept in this array.
arrayPositionelement of maInputs that has been most recently inserted
sumOfInputssum of the last 'width' inputs
uncorrectedSumsum of all inputs since object was created
expWMANo description.
bweightWeights used to calculate exponentially weighted moving averages. These depend on the specified 'width' according to: bweight = -expm1(-1.0/w);aweight = 1.0 - bweight; ewma=aweight*ma(x)+bweight*x


Method Types

- initWidth:
- initWidth:Value:
- getNumInputs
- getMA
- getAverage
- getEWMA
- addValue:
- drop

Instance Methods

addValue:

- (void)addValue:(double)x

No method description.


drop

- (void)drop

No method description.


getAverage

- (double)getAverage

No method description.


getEWMA

- (double)getEWMA

No method description.


getMA

- (double)getMA

No method description.


getNumInputs

- (int)getNumInputs

No method description.


initWidth:

- initWidth:(int)w

No method description.


initWidth:Value:

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

No method description.


Version 1.1 Copyright ©2001. All Rights Reserved.