line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Statistics::Basic; |
3
|
|
|
|
|
|
|
|
4
|
65
|
|
|
65
|
|
145799
|
use strict; |
|
65
|
|
|
|
|
91
|
|
|
65
|
|
|
|
|
1390
|
|
5
|
65
|
|
|
65
|
|
297
|
use warnings; |
|
65
|
|
|
|
|
81
|
|
|
65
|
|
|
|
|
1712
|
|
6
|
65
|
|
|
65
|
|
296
|
use Carp; |
|
65
|
|
|
|
|
84
|
|
|
65
|
|
|
|
|
2268
|
|
7
|
|
|
|
|
|
|
|
8
|
65
|
|
|
65
|
|
20874
|
use Number::Format; |
|
65
|
|
|
|
|
398753
|
|
|
65
|
|
|
|
|
5715
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.6610'; |
11
|
|
|
|
|
|
|
our $fmt = new Number::Format; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our( $NOFILL, $DEBUG, $IPRES, $TOLER, $UNBIAS ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
BEGIN { |
16
|
65
|
50
|
|
65
|
|
295
|
$NOFILL = exists($ENV{NOFILL}) ? $ENV{NOFILL} : 0; |
17
|
65
|
50
|
|
|
|
134
|
$DEBUG = exists($ENV{DEBUG_STATS_B}) ? $ENV{DEBUG_STATS_B} : 0; |
18
|
65
|
50
|
|
|
|
520
|
$IPRES = exists($ENV{IPRES}) ? $ENV{IPRES} : 2; |
19
|
65
|
100
|
|
|
|
813
|
$TOLER = $ENV{TOLER} if exists $ENV{TOLER}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
65
|
|
|
65
|
|
304
|
use base 'Exporter'; |
|
65
|
|
|
|
|
515
|
|
|
65
|
|
|
|
|
13475
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our @EXPORT_OK = (qw( |
25
|
|
|
|
|
|
|
vector computed |
26
|
|
|
|
|
|
|
mean average avg |
27
|
|
|
|
|
|
|
median |
28
|
|
|
|
|
|
|
mode |
29
|
|
|
|
|
|
|
variance var |
30
|
|
|
|
|
|
|
stddev |
31
|
|
|
|
|
|
|
covariance cov |
32
|
|
|
|
|
|
|
correlation cor corr |
33
|
|
|
|
|
|
|
leastsquarefit LSF lsf |
34
|
|
|
|
|
|
|
handle_missing_values handle_missing |
35
|
|
|
|
|
|
|
)); |
36
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( all => \@EXPORT_OK ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub import { |
39
|
197
|
|
|
197
|
|
496
|
my @special = (); |
40
|
|
|
|
|
|
|
|
41
|
197
|
|
|
|
|
482
|
@_ = grep { m/^(ignore_env|nofill|debug|ipres|toler|unbias)(?:=([\d\.\-_]+))?\z/i |
|
20
|
|
|
|
|
110
|
|
42
|
244
|
100
|
|
|
|
1655
|
? do {push @special, [lc($1), $2]; 0} : 1 } |
|
20
|
|
|
|
|
62
|
|
43
|
|
|
|
|
|
|
@_; |
44
|
|
|
|
|
|
|
|
45
|
197
|
100
|
|
|
|
549
|
if( grep {$_->[0] =~ m/ignore_env/} @special ) { |
|
20
|
|
|
|
|
108
|
|
46
|
5
|
|
|
|
|
37
|
delete $ENV{TOLER}; |
47
|
5
|
|
|
|
|
6
|
$NOFILL = 0; |
48
|
5
|
|
|
|
|
5
|
$DEBUG = 0; |
49
|
5
|
|
|
|
|
10
|
$IPRES = 2; |
50
|
5
|
|
|
|
|
6
|
$TOLER = undef; |
51
|
5
|
|
|
|
|
7
|
$UNBIAS = 0; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
197
|
|
|
|
|
460
|
for( grep {$_->[0] !~ m/ignore_env/} @special ) { |
|
20
|
|
|
|
|
62
|
|
55
|
15
|
|
|
|
|
29
|
my ($k, $v) = @$_; |
56
|
15
|
100
|
|
|
|
632
|
$v = eval $v if defined $v; ## no critic |
57
|
|
|
|
|
|
|
|
58
|
15
|
100
|
|
|
|
81
|
if( lc($k) eq "ipres" ) { |
|
|
100
|
|
|
|
|
|
59
|
3
|
100
|
|
|
|
11
|
$v = 2 unless defined($v); |
60
|
3
|
50
|
|
|
|
14
|
croak "bad ipres value ($v)" unless $v >= 0; |
61
|
3
|
|
|
|
|
11
|
$IPRES = $v; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} elsif( lc($k) eq "toler" ) { |
64
|
5
|
100
|
|
|
|
17
|
if( defined $v ) { |
65
|
4
|
50
|
|
|
|
14
|
croak "bad toler value($v)" unless $v >= 0; |
66
|
4
|
|
|
|
|
11
|
$TOLER = $v; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} else { |
69
|
1
|
|
|
|
|
3
|
$TOLER = undef; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
} else { |
73
|
65
|
|
|
65
|
|
256
|
no strict 'refs'; ## no critic |
|
65
|
|
|
|
|
622
|
|
|
65
|
|
|
|
|
25302
|
|
74
|
7
|
100
|
|
|
|
21
|
${uc($k)} = defined($v) ? $v : 1; ## no critic |
|
7
|
|
|
|
|
27
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
197
|
|
|
|
|
295
|
my $pull = q { |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
use Statistics::Basic::Covariance; |
81
|
|
|
|
|
|
|
use Statistics::Basic::Correlation; |
82
|
|
|
|
|
|
|
use Statistics::Basic::LeastSquareFit; |
83
|
|
|
|
|
|
|
use Statistics::Basic::Mean; |
84
|
|
|
|
|
|
|
use Statistics::Basic::Median; |
85
|
|
|
|
|
|
|
use Statistics::Basic::Mode; |
86
|
|
|
|
|
|
|
use Statistics::Basic::StdDev; |
87
|
|
|
|
|
|
|
use Statistics::Basic::Variance; |
88
|
|
|
|
|
|
|
use Statistics::Basic::Vector; |
89
|
|
|
|
|
|
|
use Statistics::Basic::ComputedVector; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
}; |
94
|
|
|
|
|
|
|
|
95
|
65
|
50
|
|
65
|
|
15545
|
eval $pull or die "problem loading base modules: $@"; ## no critic |
|
65
|
|
|
65
|
|
595
|
|
|
65
|
|
|
65
|
|
1089
|
|
|
65
|
|
|
33
|
|
201
|
|
|
65
|
|
|
33
|
|
555
|
|
|
65
|
|
|
33
|
|
977
|
|
|
65
|
|
|
33
|
|
12463
|
|
|
65
|
|
|
33
|
|
324
|
|
|
33
|
|
|
33
|
|
888
|
|
|
33
|
|
|
33
|
|
13514
|
|
|
33
|
|
|
33
|
|
76
|
|
|
33
|
|
|
33
|
|
1011
|
|
|
33
|
|
|
33
|
|
12935
|
|
|
33
|
|
|
33
|
|
79
|
|
|
33
|
|
|
33
|
|
936
|
|
|
33
|
|
|
33
|
|
646
|
|
|
33
|
|
|
33
|
|
44
|
|
|
33
|
|
|
33
|
|
767
|
|
|
33
|
|
|
33
|
|
607
|
|
|
33
|
|
|
33
|
|
44
|
|
|
33
|
|
|
33
|
|
609
|
|
|
33
|
|
|
33
|
|
133
|
|
|
33
|
|
|
33
|
|
48
|
|
|
33
|
|
|
33
|
|
612
|
|
|
33
|
|
|
33
|
|
141
|
|
|
33
|
|
|
33
|
|
35
|
|
|
33
|
|
|
33
|
|
688
|
|
|
33
|
|
|
33
|
|
11860
|
|
|
33
|
|
|
33
|
|
60
|
|
|
33
|
|
|
33
|
|
872
|
|
|
33
|
|
|
33
|
|
11579
|
|
|
33
|
|
|
33
|
|
84
|
|
|
33
|
|
|
33
|
|
919
|
|
|
33
|
|
|
33
|
|
163
|
|
|
33
|
|
|
33
|
|
44
|
|
|
33
|
|
|
33
|
|
757
|
|
|
33
|
|
|
33
|
|
181
|
|
|
33
|
|
|
33
|
|
37
|
|
|
33
|
|
|
33
|
|
671
|
|
|
33
|
|
|
33
|
|
653
|
|
|
33
|
|
|
33
|
|
39
|
|
|
33
|
|
|
33
|
|
575
|
|
|
33
|
|
|
33
|
|
609
|
|
|
33
|
|
|
33
|
|
37
|
|
|
33
|
|
|
33
|
|
615
|
|
|
33
|
|
|
33
|
|
693
|
|
|
33
|
|
|
33
|
|
41
|
|
|
33
|
|
|
33
|
|
555
|
|
|
33
|
|
|
33
|
|
160
|
|
|
33
|
|
|
33
|
|
50
|
|
|
33
|
|
|
|
|
753
|
|
|
33
|
|
|
|
|
11998
|
|
|
33
|
|
|
|
|
184
|
|
|
33
|
|
|
|
|
1074
|
|
|
33
|
|
|
|
|
11139
|
|
|
33
|
|
|
|
|
60
|
|
|
33
|
|
|
|
|
820
|
|
|
33
|
|
|
|
|
11977
|
|
|
33
|
|
|
|
|
72
|
|
|
33
|
|
|
|
|
822
|
|
|
33
|
|
|
|
|
176
|
|
|
33
|
|
|
|
|
59
|
|
|
33
|
|
|
|
|
866
|
|
|
33
|
|
|
|
|
146
|
|
|
33
|
|
|
|
|
45
|
|
|
33
|
|
|
|
|
623
|
|
|
33
|
|
|
|
|
120
|
|
|
33
|
|
|
|
|
44
|
|
|
33
|
|
|
|
|
542
|
|
|
33
|
|
|
|
|
122
|
|
|
33
|
|
|
|
|
44
|
|
|
33
|
|
|
|
|
548
|
|
|
33
|
|
|
|
|
130
|
|
|
33
|
|
|
|
|
36
|
|
|
33
|
|
|
|
|
512
|
|
|
33
|
|
|
|
|
637
|
|
|
33
|
|
|
|
|
32
|
|
|
33
|
|
|
|
|
498
|
|
|
33
|
|
|
|
|
116
|
|
|
33
|
|
|
|
|
46
|
|
|
33
|
|
|
|
|
557
|
|
|
33
|
|
|
|
|
155
|
|
|
33
|
|
|
|
|
51
|
|
|
33
|
|
|
|
|
515
|
|
|
33
|
|
|
|
|
127
|
|
|
33
|
|
|
|
|
36
|
|
|
33
|
|
|
|
|
696
|
|
|
33
|
|
|
|
|
12170
|
|
|
33
|
|
|
|
|
68
|
|
|
33
|
|
|
|
|
445
|
|
|
33
|
|
|
|
|
159
|
|
|
33
|
|
|
|
|
37
|
|
|
33
|
|
|
|
|
757
|
|
|
33
|
|
|
|
|
136
|
|
|
33
|
|
|
|
|
43
|
|
|
33
|
|
|
|
|
575
|
|
|
33
|
|
|
|
|
124
|
|
|
33
|
|
|
|
|
37
|
|
|
33
|
|
|
|
|
559
|
|
|
33
|
|
|
|
|
114
|
|
|
33
|
|
|
|
|
34
|
|
|
33
|
|
|
|
|
493
|
|
|
33
|
|
|
|
|
137
|
|
|
33
|
|
|
|
|
40
|
|
|
33
|
|
|
|
|
517
|
|
|
33
|
|
|
|
|
122
|
|
|
33
|
|
|
|
|
38
|
|
|
33
|
|
|
|
|
458
|
|
|
33
|
|
|
|
|
116
|
|
|
33
|
|
|
|
|
64
|
|
|
33
|
|
|
|
|
527
|
|
|
33
|
|
|
|
|
123
|
|
|
33
|
|
|
|
|
39
|
|
|
33
|
|
|
|
|
535
|
|
|
33
|
|
|
|
|
126
|
|
|
33
|
|
|
|
|
50
|
|
|
33
|
|
|
|
|
486
|
|
|
33
|
|
|
|
|
115
|
|
|
33
|
|
|
|
|
33
|
|
|
33
|
|
|
|
|
475
|
|
|
33
|
|
|
|
|
164
|
|
|
33
|
|
|
|
|
41
|
|
|
33
|
|
|
|
|
339
|
|
|
33
|
|
|
|
|
163
|
|
|
33
|
|
|
|
|
57
|
|
|
33
|
|
|
|
|
577
|
|
|
33
|
|
|
|
|
129
|
|
|
33
|
|
|
|
|
44
|
|
|
33
|
|
|
|
|
475
|
|
|
33
|
|
|
|
|
120
|
|
|
33
|
|
|
|
|
47
|
|
|
33
|
|
|
|
|
528
|
|
|
33
|
|
|
|
|
141
|
|
|
33
|
|
|
|
|
42
|
|
|
33
|
|
|
|
|
280
|
|
|
33
|
|
|
|
|
159
|
|
|
33
|
|
|
|
|
44
|
|
|
33
|
|
|
|
|
556
|
|
|
33
|
|
|
|
|
140
|
|
|
33
|
|
|
|
|
48
|
|
|
33
|
|
|
|
|
513
|
|
|
33
|
|
|
|
|
124
|
|
|
33
|
|
|
|
|
42
|
|
|
33
|
|
|
|
|
602
|
|
|
33
|
|
|
|
|
129
|
|
|
33
|
|
|
|
|
42
|
|
|
33
|
|
|
|
|
653
|
|
|
33
|
|
|
|
|
123
|
|
|
33
|
|
|
|
|
69
|
|
|
33
|
|
|
|
|
577
|
|
|
197
|
|
|
|
|
12983
|
|
96
|
|
|
|
|
|
|
|
97
|
197
|
|
|
|
|
80042
|
return __PACKAGE__->export_to_level(1, @_); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
12
|
50
|
|
12
|
1
|
33
|
sub computed { my $r = eval { Statistics::Basic::ComputedVector->new(@_) } or croak $@; return $r } |
|
12
|
|
|
|
|
78
|
|
|
12
|
|
|
|
|
37
|
|
101
|
|
|
|
|
|
|
|
102
|
18
|
50
|
|
18
|
1
|
11034
|
sub vector { my $r = eval { Statistics::Basic::Vector->new(@_) } or croak $@; return $r } |
|
18
|
|
|
|
|
183
|
|
|
18
|
|
|
|
|
53
|
|
103
|
26
|
50
|
|
26
|
1
|
10356
|
sub mean { my $r = eval { Statistics::Basic::Mean->new(@_) } or croak $@; return $r } |
|
26
|
|
|
|
|
183
|
|
|
26
|
|
|
|
|
160
|
|
104
|
10
|
50
|
|
10
|
1
|
28
|
sub median { my $r = eval { Statistics::Basic::Median->new(@_) } or croak $@; return $r } |
|
10
|
|
|
|
|
52
|
|
|
10
|
|
|
|
|
28
|
|
105
|
2
|
50
|
|
2
|
1
|
4
|
sub mode { my $r = eval { Statistics::Basic::Mode->new(@_) } or croak $@; return $r } |
|
2
|
|
|
|
|
23
|
|
|
2
|
|
|
|
|
8
|
|
106
|
2
|
50
|
|
2
|
1
|
6
|
sub variance { my $r = eval { Statistics::Basic::Variance->new(@_) } or croak $@; return $r } |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
5
|
|
107
|
14
|
50
|
|
14
|
1
|
37
|
sub stddev { my $r = eval { Statistics::Basic::StdDev->new(@_) } or croak $@; return $r } |
|
14
|
|
|
|
|
73
|
|
|
14
|
|
|
|
|
42
|
|
108
|
|
|
|
|
|
|
|
109
|
2
|
50
|
|
2
|
1
|
281
|
sub covariance { my $r = eval { Statistics::Basic::Covariance->new( $_[0], $_[1] ) } or croak $@; return $r } |
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
14
|
|
110
|
6
|
50
|
|
6
|
1
|
21
|
sub correlation { my $r = eval { Statistics::Basic::Correlation->new( $_[0], $_[1] ) } or croak $@; return $r } |
|
6
|
|
|
|
|
54
|
|
|
6
|
|
|
|
|
21
|
|
111
|
1
|
50
|
|
1
|
1
|
4
|
sub leastsquarefit { my $r = eval { Statistics::Basic::LeastSquareFit->new( $_[0], $_[1] ) } or croak $@; return $r } |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
3
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub handle_missing_values { |
114
|
2
|
|
|
2
|
1
|
7
|
my ($v1,$v2) = @_; |
115
|
|
|
|
|
|
|
|
116
|
2
|
50
|
|
|
|
3
|
my $v3 = eval { computed($v1) } or croak $@; |
|
2
|
|
|
|
|
5
|
|
117
|
2
|
50
|
|
|
|
9
|
my $v4 = eval { computed($v2) } or croak $@; |
|
2
|
|
|
|
|
4
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
$v3->set_filter(sub { |
120
|
2
|
|
|
2
|
|
7
|
my @v = $v2->query; |
121
|
2
|
100
|
|
|
|
7
|
map {$_[$_]} grep { defined $v[$_] and defined $_[$_] } 0 .. $#_; |
|
8
|
|
|
|
|
15
|
|
|
13
|
|
|
|
|
80
|
|
122
|
2
|
|
|
|
|
15
|
}); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
$v4->set_filter(sub { |
125
|
2
|
|
|
2
|
|
11
|
my @v = $v1->query; |
126
|
2
|
100
|
|
|
|
6
|
map {$_[$_]} grep { defined $v[$_] and defined $_[$_] } 0 .. $#_; |
|
8
|
|
|
|
|
13
|
|
|
13
|
|
|
|
|
51
|
|
127
|
2
|
|
|
|
|
10
|
}); |
128
|
|
|
|
|
|
|
|
129
|
2
|
|
|
|
|
6
|
return ($v3,$v4); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
*handle_missing = \&handle_missing_values; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
*average = *mean; |
134
|
|
|
|
|
|
|
*avg = *mean; |
135
|
|
|
|
|
|
|
*var = *variance; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
*cov = *covariance; |
138
|
|
|
|
|
|
|
*cor = *correlation; |
139
|
|
|
|
|
|
|
*corr = *correlation; |
140
|
|
|
|
|
|
|
*lsf = *leastsquarefit; |
141
|
|
|
|
|
|
|
*LSF = *leastsquarefit; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |