NAME
Statistics::DEA - Discontiguous Exponential Averaging
SYNOPSIS
use Statistics::DEA;
my $dea = Statistics::DEA->new($alpha, $max_gap);
while (($data, $time) = some_data_source(...)) {
...
$dea->update($data, $time);
print $dea->average(), "\n";
print $dea->standard_deviation(), "\n";
print $dea->completeness($time), "\n";
...
}
DESCRIPTION
The Statistics::DEA module can be used to compute exponentially decaying averages even when the data has gaps. The algorithm also avoids initial value bias and postgap bias.
new
my $dea = Statistics::DEA->new($alpha, $max_gap);
Creates a new (potentially discontiguous) exponential average object.
The $alpha is the exponential decay of data: from zero (inclusive) to one (exclusive): the lower values cause the effect of data to decay more quickly, the higher values cause the effect of data to decay more slowly.
The $max_gap is the maximum time gap after which the data is considered lost (decay should bring the average to zero).
update
$dea->update($data, $time);
Update the average with new data at a particular point in time.
The time parameter is how you can indicate gaps in the data; if you don't have gaps in your data, just monotonously increase it, for example $time++
.
average
my $avg = $dea->average();
Return the current average.
Functionally equivalent alias avg() is also available.
standard_deviation
my $std_dev = $dea->standard_deviation();
Return the current standard deviation.
Functionally equivalent alias std_dev() is also available.
completeness
my $completeness = $dea->completeness();
Return the current completeness: how well based the current average and standard deviation are on actual data. Any gaps reduce this value.
alpha
my $alpha = $dea->alpha();
Return the current exponential decay of data.
$dea->alpha($alpha);
Set the exponential decay of data.
max_gap
my $alpha = $dea->alpha();
Return the current maximum time gap.
$dea->max_gap($max_gap);
Set the maximum time gap.
AUTHOR
Jarkko Hietaniemi <jhi@iki.fi>
ACKNOWLEDGEMENT
The idea and the code is from the September 1998 Doctor Dobb's Journal Algorithm Alley article "Discontiguous Exponential Averaging" by John C. Gunther, used with permission. This is just a Perlification of the code, all errors in transcription are solely mine.