in reply to Re: Least Squares in Perlin thread Least Squares in Perl
remove call to sum() out of the loop !
my $sum_x = Sum(@x); $xy_res[$i] = abs($y[$i] - ($sum_y/$n))*abs($x[$i] - ($sum_x/$n)); [download]