|
use Statistics::LineFit;
$lineFit = Statistics::LineFit->new();
$lineFit->setData(\@x, \@y) or die "Invalid regression data\n";
if (defined $lineFit->rSquared()
and $lineFit->rSquared() > $threshold)
{
($intercept, $slope) = $lineFit->coefficients();
print "Slope: $slope Y-intercept: $intercept\n";
}
I have picked the example from http://search.cpan.org/~randerson/Statistics-LineFit-0.07/lib/Statistics/LineFit.pm
You can get the details of this module from the above url.
Cheers. |