dotfiles/bin/movingaverage
michener 83d40113d2 First import
git-svn-id: http://photonzero.com/dotfiles/trunk@1 23f722f6-122a-0410-8cef-c75bd312dd78
2007-03-19 06:17:17 +00:00

21 lines
362 B
Perl
Executable file

#!/usr/bin/perl
$averageto = $ARGV[0];
for ($i = 0; $i < $averageto; $i++) {
$temp[$i] = 0;
}
while (<STDIN>) {
chomp;
$x = 0;
for ($i = 0; $i < $averageto; $i++) {
$x += $temp[$i];
}
$x = $x + $_;
$x = $x / ($averageto + 1);
print "$x\n";
for ($i = 0; $i < $averageto - 1; $i++) {
$temp[$i] = $temp[($i + 1)];
}
$temp[($averageto -1)] = $_;
}