Algorithm-Burg
view release on metacpan or search on metacpan
VERSION
version 0.001
SYNOPSIS
DESCRIPTION
The Algorithm::Burg module uses the Burg method to fit an
autoregressive (AR) model to the input data by minimizing (least
squares) the forward and backward prediction errors while constraining
the AR parameters to satisfy the Levinson-Durbin recursion.
DISCLAIMER: This is work in progress! The code is buggy and the
interface is subject to change.
ATTRIBUTES
coefficients
AR model polynomial coefficients computed by the train method.
lib/Algorithm/Burg.pm view on Meta::CPAN
=head1 VERSION
version 0.001
=head1 SYNOPSIS
=head1 DESCRIPTION
The L<Algorithm::Burg> module uses the Burg method to fit an autoregressive (AR)
model to the input data by minimizing (least squares) the forward and backward
prediction errors while constraining the AR parameters to satisfy the
Levinson-Durbin recursion.
B<DISCLAIMER: This is work in progress! The code is buggy and the interface is subject to change.>
=head1 ATTRIBUTES
=head2 coefficients
AR model polynomial coefficients computed by the C<train> method.
t/01-coeffs.t view on Meta::CPAN
$burg->train([
map {
1.0 * cos($_ * 0.01) + 0.75 * cos($_ * 0.03)
+ 0.5 * cos($_ * 0.05) + 0.25 * cos($_ * 0.11)
} 0 .. 127
])
};
is($#coeff1, $#coeff2, 'order');
my $error = 0.0;
my $epsilon = 1e-9;
for my $i (0 .. $#coeff1) {
my $delta = $coeff1[$i] - $coeff2[$i];
$error += $delta * $delta;
}
ok($error < $epsilon, "error < epsilon ($error)");
t/02-predict.t view on Meta::CPAN
$burg->train([ @whole_series[0 .. 64] ]);
my @original = @whole_series[64 .. $#whole_series];
my @predicted = @{ $burg->predict(64) };
is($#original, $#predicted, 'cardinality');
# use Data::Dumper;
# diag Dumper(\@original, \@predicted);
my $error = 0.0;
my $epsilon = 3.0;
for my $i (0 .. $#original) {
my $delta = $original[$i] - $predicted[$i];
$error += $delta * $delta;
}
ok($error < $epsilon, "error < epsilon ($error)");
( run in 0.651 second using v1.01-cache-2.11-cpan-65fba6d93b7 )