Win has asked for the wisdom of the Perl Monks concerning the following question:

My Dearest Monks,

I
use Statistics::LineFit;
in the context of
sub correlation { my ($x_ref, $y_ref) = @_; my $output = "output_test.txt"; open (OUTPUT_TEST, ">$output"); print OUTPUT_TEST Dumper ($x_ref, $y_ref); #print Dumper length($x_ref); #print Dumper length($y_ref); my $lfit = Statistics::LineFit->new(); $lfit->setData($x_ref, $y_ref); my ($intercept, $slope) = $lfit->coefficients(); my $rSquared = $lfit->rSquared(); my $hashref = { a => $intercept, b => $slope, c => $rSquared }; return $hashref; }
Is there a quick and easy way for me to return all the points that exist above the trend line and all the points that exist below the trend line as two seperate groups (in two arrays).

Replies are listed 'Best First'.
Re: Cluster points above and below trendline with use Statistics::LineFit;
by moklevat (Priest) on Dec 05, 2007 at 16:27 UTC
    Above and below the trend line are defined by $y_ref.

    Points above the trend line are:

    $y_ref > $intercept + ($x_ref * $slope)

    Points below the trend line are:

    $y_ref < $intercept + ($x_ref * $slope)

      Thanks, this is a good start. $y_ref and $x_ref are references to arrays, however.