Serial Average
Just because I keep forgetting it and having to find out all the math manually again!
my $avg = 0; my $cnt = 0; for my $row (@rows) { if ($cnt) { $avg += (($row->{value} - $avg)/$cnt)*$row->{cnt}; $cnt += $row->{cnt}; } else { $cnt = $row->{cnt}; $avg = $row->{value}; } }
Source: theMage