leto / math--gsl

Perl interface to the GNU Scientific Library

commit  19ceffe3869857fdd6f4f68041ce2b6c42d20626
tree    75257c726adb1a5d131b0976faeaa1d33ddcba10
parent  0d31838589c7a0a5351e02c7395d7292a6eea44b
math--gsl / examples / correlation
100755 21 lines (17 sloc) 0.471 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/perl -w
use Math::GSL::Statistics qw/gsl_stats_correlation/;
use strict;
 
my $data1 = [
            17, 18, 16, 18, 12,
            20, 18, 20, 20, 22,
            20, 10, 8, 12, 16,
            16, 18, 20, 18, 21
            ];
 
my $data2 = [
            19, 20, 22, 24, 10,
            25, 20, 22, 21, 23,
            20, 10, 12, 14, 12,
            20, 22, 24, 23, 17
            ];
 
my $x = gsl_stats_correlation($data1, 1, $data2, 1, 20);
print "x=$x\n";