Math-EMA
view release on metacpan or search on metacpan
perl Makefile.PL
make
make test
make install
DEPENDENCIES
* perl 5.8.0
DESCRIPTION
This module computes an exponential moving average by the following
formula
avg(n+1) = (1 - alpha) * new_value + alpha * avg(n)
where alpha is a number between 0 and 1.
That means a new value influences the average with a certain weight
(1-alpha). That weight then exponentially vanes when other values are
added.
How to choose alpha?
lib/Math/EMA.pm view on Meta::CPAN
use Math::EMA;
my $avg=Math::EMA->new(alpha=>0.926119, ema=>$initial_value);
$avg->set_param($iterations, $end_weight);
$avg->alpha=$new_alpha;
$avg->ema=$new_value;
$avg->add($some_value);
my $ema=$avg->ema;
=head1 DESCRIPTION
This module computes an exponential moving average by the following formula
avg(n+1) = (1 - alpha) * new_value + alpha * avg(n)
where alpha is a number between 0 and 1.
That means a new value influences the average with a certain weight (1-alpha).
That weight then exponentially vanes when other values are added.
=head2 How to choose alpha?
( run in 0.715 second using v1.01-cache-2.11-cpan-26ccb49234f )