~ubuntu-branches/ubuntu/natty/libstatistics-basic-perl/natty

« back to all changes in this revision

Viewing changes to t/20_correlation.t

  • Committer: Bazaar Package Importer
  • Author(s): Ryan Niebur, Nathan Handler, Ryan Niebur
  • Date: 2009-07-01 20:22:06 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 karmic)
  • Revision ID: james.westby@ubuntu.com-20090701202206-0co1izn0pj047x4i
Tags: 1.6600-1
[ Nathan Handler ]
* debian/watch: Update to ignore development releases.

[ Ryan Niebur ]
* New upstream release
* Debian Policy 3.8.2
* enable author tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
BEGIN { $ENV{TOLER} = 0.000_001; }
2
 
 
3
1
use strict;
4
2
use Test;
5
 
use Statistics::Basic qw(:all);
 
3
use Statistics::Basic qw(:all toler=0.000_001);
6
4
 
7
5
plan tests => 7;
8
6
 
9
7
my  $corr = new Statistics::Basic::Correlation([1 .. 10], [1 .. 10]);
10
 
ok( $corr == 1 );
 
8
ok( $corr == 1 )
 
9
    or warn "\ncorr: $corr";
11
10
 
12
11
    $corr->insert( 11, 7 );
13
 
ok( $corr == ( (129/20) / (sqrt(609/100) * sqrt(165/20))));
 
12
ok( $corr == ( (129/20) / (sqrt(609/100) * sqrt(165/20))))
 
13
    or warn "\ncorr: $corr";
14
14
 
15
15
    $corr->set_vector( [11 .. 13], [11 .. 13] );
16
16
ok( $corr == 1 );
17
17
 
18
18
    $corr->ginsert( 13, 12 );
19
 
ok( $corr == ( (1/2) / (sqrt(11/16) * sqrt(1/2)) ));
 
19
ok( $corr == ( (1/2) / (sqrt(11/16) * sqrt(1/2)) ))
 
20
    or warn "\ncorr: $corr";
 
21
 
 
22
 
 
23
 
20
24
 
21
25
my  $j = new Statistics::Basic::Correlation;
22
26
 
23
27
    $j->set_vector( [11 .. 13], [11 .. 13] );
24
 
ok( $j == 1 );
 
28
ok( $j == 1 )
 
29
    or warn "\ncorr: $j";
 
30
 
 
31
 
 
32
 
25
33
 
26
34
my $c = correlation([4,7,7], [4,7,7]);
27
 
ok( $c == 1 );
 
35
ok( $c == 1 )
 
36
    or warn "\ncorr: $c";
28
37
 
29
38
$c->insert(3,4);
30
 
ok( $c == correlation([7,7,3], [7,7,4]) );
 
39
ok( $c, correlation([7,7,3], [7,7,4]) );