# 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,
``````

## Constructors

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

## Properties

add → T Function(List<T> data, num newValue)
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.
final
averageType
The type of calculation to use.
final
factor
The value used when calculating exponential moving averages. It should be constrained by 0.0 <= factor <= 1.0.
final
getValue num Function(T)
The function to take a value T and return a number, e.g. the y coordinate of a point.
final
hashCode int
The hash code for this object.
no setterinherited
partialStart bool
Used with simple or weighted moving averages to control whether or not to include calculations on incomplete windows at the start of the data.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
windowSize int
The window size used when calculating simple and weighted moving averages.
final

## Methods

call(List<T> data) List<T>
Invoke the configured MovingAverage calculator on data.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString()
A string representation of this object.
inherited

## Operators

operator ==(Object other) bool
The equality operator.
inherited