Created
July 12, 2012 15:21
-
-
Save jberger/3098830 to your computer and use it in GitHub Desktop.
PDL::Stats linear regression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use PDL; | |
use PDL::Stats; | |
my $x = pdl [ 1, 2, 3, 4 ]; | |
my $y = pdl [ 1.3, 2.9, 4.2, 5.4 ]; | |
# get just the coeffs: | |
my $coeffs = $y->ols( $x ); | |
print $coeffs; | |
# or get the entire results in list (hash) context | |
my %results = $y->ols( $x ); | |
print "$_\t$m{$_}\n" for (sort keys %m) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment