Math::EWMA - EWMA in object form
use Math::EWMA; my $ewma = Math::EWMA->new(alpha => $n); $ewma->ewma($value);
Implements an exponential moving average with a weight of $alpha in object form. http://en.wikipedia.org/wiki/Moving_average
$alpha
Create a new EWMA object with alpha $n.
$n
my $ewma = Math::EWMA->new(alpha => $n);
An alpha value of 2/(N+1) is roughly equivalent to a simple moving average of N periods
Add value to series and return the current exponential moving average
$ewma->ewma($current);
$current is the current live value
$current
Returns last_avg if called with no arguments.
last_avg
The precision level for decimal places. Defaults to 2.
The current value of the EWMA series. If you want to continue a series from a previous time, then pass that value in during object construction:
my $ewma = Math::EWMA->new(alpha => .125, last_avg => 45.754);
Samuel Smith <esaym@cpan.org>
See http://rt.cpan.org to report and view bugs.
The source code repository for Math::EWMA can be found at https://github.com/smith153/Math-EWMA.
Copyright 2015 by Samuel Smith <esaym@cpan.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
To install Math::EWMA, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::EWMA
CPAN shell
perl -MCPAN -e shell install Math::EWMA
For more information on module installation, please visit the detailed CPAN module installation guide.