Last updated:
0 purchases
moving average
MovingAverage #
A library for the calculation of moving averages.
Usage #
A simple usage example:
import 'package:moving_average/moving_average.dart';
main() {
final values = [1, 2, 3, 4, 5];
print("Values = $values");
// Values = [1, 2, 3, 4, 5]
final simpleMovingAverage = MovingAverage<num>(
averageType: AverageType.simple,
windowSize: 3,
partialStart: true,
getValue: (num n) => n,
add: (List<num> data, num value) => value,
);
final movingAverage3 = simpleMovingAverage(values);
print("Moving Average, size 3, partial = $movingAverage3");
// Moving Average, size 3, partial = [1.0, 1.5, 2.0, 3.0, 4.0]
final weightedMovingAverage = MovingAverage<num>(
averageType: AverageType.weighted,
windowSize: 3,
getValue: (num n) => n,
add: (List<num> data, num value) => value,
);
final weightedAverage3 = weightedMovingAverage(values);
print("Weighted Moving Average, size 3 = $weightedAverage3");
// Weighted Moving Average, size 3 = [2.3333333333333335, 3.3333333333333335, 4.333333333333333]
}
copied to clipboard
Features and bugs #
Please file feature requests and bugs at the issue tracker.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.