MovingAverage<T> class

A class to calculate simple, weighted or exponential moving averages of lists of objects.

averageType is the type of calculation to use. windowSize is the window size used when calculating simple and weighted moving averages. partialStart is used with simple or weighted moving averages to control whether or not to include calculations on incomplete windows at the start of the data. factor is the value used when calculating exponential moving averages. It should be constrained by 0.0 <= factor <= 1.0. getValue is a function to take a value T and return a number, e.g. the y coordinate of a point. add is a function to take a list of inputs, and an average value, and create a new data point from the data points and the new value. Examples include using the middle x value of a set of points for the x value of the resulting point, and the new average for the y value.

For calculations on lists of numbers, not objects, use the following for getValue and add:

getValue: (num n) => n,
add: (List<num> data, num value) => value,


MovingAverage({AverageType averageType: AverageType.simple, int windowSize: 1, bool partialStart: false, double factor: 1.0, num getValue(T), T add(List<T> data, num newValue)})
Instantiate the class with the gven parameters


add → T Function(List<T> data, num newValue)
averageType AverageType
factor double
getValue num Function(T)
hashCode int
The hash code for this object. [...]
read-only, inherited
partialStart bool
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
windowSize int


call(List<T> data) List<T>
Invoke the configured MovingAverage calculator on data.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toString() String
Returns a string representation of this object.


operator ==(Object other) bool
The equality operator. [...]