NAME

Statistics::Basic::LeastSquareFit

SYNOPSIS

A machine to calculate the Least Square Fit of given vectors x and y.

The module returns alpha and beta from the formula:

y = alpha + beta * x

ENV VARIABLES

DEBUG

Try setting $ENV{DEBUG}=1; or $ENV{DEBUG}=2; to see the internals.

Also, from your bash prompt you can 'DEBUG=1 perl ./myprog.pl' to enable debugging dynamically.

EXAMPLE (written for Satish <dachs@mri>)

use strict;
use Statistics::Basic::LeastSquareFit;

STYLE_ONE: {
    open F1, $ARGV[0] or die "couldn't open first file: $!";
    open F2, $ARGV[1] or die "couldn't open second file: $!";

    my $v1 = [ map(int $_, <F1>) ];
    my $v2 = [ map(int $_, <F2>) ];

    my $lsf = new Statistics::Basic::LeastSquareFit($v1, $v2);

    close F1;
    close F2;

    my ($alpha, $beta) = $lsf->query;

    print "STYLE_ONE: \$alpha = $alpha; \$beta = $beta\n";
}

STYLE_TWO: {
    my $lsf = new Statistics::Basic::LeastSquareFit();

    open F1, $ARGV[0] or die "couldn't open first file: $!";
    open F2, $ARGV[1] or die "couldn't open second file: $!";
    
    while(my $f1 = <F1> and my $f2 = <F2>) {

        $lsf->ginsert( $f1, $f2 ); 

        # The growing insert increases the size of the vectors 
        # on each insert.  The non-growing insert shifts older 
        # values back off the queue (for a moving average).

    }

    close F1;
    close F2;

    my ($alpha, $beta) = $lsf->query;

    print "STYLE_TWO: \$alpha = $alpha; \$beta = $beta\n";
}

AUTHOR

Please contact me with ANY suggestions, no matter how pedantic.

Jettero Heller <japh@voltar-confed.org>

SEE ALSO

perl(1)