line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Statistics::Basic::Mean; |
3
|
|
|
|
|
|
|
|
4
|
33
|
|
|
33
|
|
156
|
use strict; |
|
33
|
|
|
|
|
51
|
|
|
33
|
|
|
|
|
1393
|
|
5
|
33
|
|
|
33
|
|
148
|
use warnings; |
|
33
|
|
|
|
|
41
|
|
|
33
|
|
|
|
|
977
|
|
6
|
33
|
|
|
33
|
|
154
|
use Carp; |
|
33
|
|
|
|
|
41
|
|
|
33
|
|
|
|
|
2380
|
|
7
|
|
|
|
|
|
|
|
8
|
33
|
|
|
33
|
|
220
|
use base 'Statistics::Basic::_OneVectorBase'; |
|
33
|
|
|
|
|
48
|
|
|
33
|
|
|
|
|
13658
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
115
|
|
|
115
|
1
|
1371
|
my $class = shift; |
12
|
|
|
|
|
|
|
|
13
|
115
|
50
|
|
|
|
268
|
warn "[new $class]\n" if $Statistics::Basic::DEBUG >= 2; |
14
|
|
|
|
|
|
|
|
15
|
115
|
|
|
|
|
263
|
my $this = bless {}, $class; |
16
|
115
|
50
|
|
|
|
135
|
my $vector = eval { Statistics::Basic::Vector->new(@_) } or croak $@; |
|
115
|
|
|
|
|
494
|
|
17
|
115
|
100
|
|
|
|
325
|
my $c = $vector->_get_computer("mean"); return $c if defined $c; |
|
115
|
|
|
|
|
548
|
|
18
|
|
|
|
|
|
|
|
19
|
76
|
|
|
|
|
1627
|
$this->{v} = $vector; |
20
|
|
|
|
|
|
|
|
21
|
76
|
|
|
|
|
235
|
$vector->_set_computer( mean => $this ); |
22
|
|
|
|
|
|
|
|
23
|
76
|
|
|
|
|
387
|
return $this; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _recalc { |
27
|
107
|
|
|
107
|
|
125
|
my $this = shift; |
28
|
107
|
|
|
|
|
125
|
my $sum = 0; |
29
|
107
|
|
|
|
|
133
|
my $v = $this->{v}; |
30
|
107
|
|
|
|
|
306
|
my $cardinality = $v->query_size; |
31
|
|
|
|
|
|
|
|
32
|
107
|
|
|
|
|
201
|
delete $this->{recalc_needed}; |
33
|
107
|
|
|
|
|
143
|
delete $this->{_value}; |
34
|
|
|
|
|
|
|
|
35
|
107
|
100
|
|
|
|
224
|
return unless $cardinality > 0; |
36
|
106
|
100
|
|
|
|
254
|
return unless $v->query_filled; # only applicable in certain circumstances |
37
|
|
|
|
|
|
|
|
38
|
33
|
|
|
33
|
|
212
|
{ no warnings 'uninitialized'; ## no critic |
|
33
|
|
|
|
|
50
|
|
|
33
|
|
|
|
|
3872
|
|
|
104
|
|
|
|
|
108
|
|
39
|
104
|
|
|
|
|
237
|
$sum += $_ for $v->query; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
104
|
|
|
|
|
4921
|
$this->{_value} = ($sum / $cardinality); |
43
|
|
|
|
|
|
|
|
44
|
104
|
50
|
|
|
|
2100
|
warn "[recalc " . ref($this) . "] ($sum/$cardinality) = $this->{_value}\n" if $Statistics::Basic::DEBUG; |
45
|
|
|
|
|
|
|
|
46
|
104
|
|
|
|
|
208
|
return; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |