line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Statistics::Descriptive::Smoother; |
2
|
|
|
|
|
|
|
$Statistics::Descriptive::Smoother::VERSION = '3.0800'; |
3
|
11
|
|
|
11
|
|
173922
|
use strict; |
|
11
|
|
|
|
|
40
|
|
|
11
|
|
|
|
|
263
|
|
4
|
11
|
|
|
11
|
|
45
|
use warnings; |
|
11
|
|
|
|
|
15
|
|
|
11
|
|
|
|
|
255
|
|
5
|
|
|
|
|
|
|
|
6
|
11
|
|
|
11
|
|
43
|
use Carp qw/ carp /; |
|
11
|
|
|
|
|
31
|
|
|
11
|
|
|
|
|
3389
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
## no critic (ProhibitExplicitReturnUndef) |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub instantiate |
11
|
|
|
|
|
|
|
{ |
12
|
16
|
|
|
16
|
1
|
5163
|
my ( $class, $args ) = @_; |
13
|
|
|
|
|
|
|
|
14
|
16
|
|
|
|
|
32
|
my $method = delete $args->{method}; |
15
|
16
|
|
100
|
|
|
58
|
my $coeff = delete $args->{coeff} || 0; |
16
|
16
|
|
|
|
|
27
|
my $ra_samples = delete $args->{samples}; |
17
|
16
|
|
|
|
|
23
|
my $ra_data = delete $args->{data}; |
18
|
|
|
|
|
|
|
|
19
|
16
|
100
|
100
|
|
|
66
|
if ( $coeff < 0 || $coeff > 1 ) |
20
|
|
|
|
|
|
|
{ |
21
|
2
|
|
|
|
|
248
|
carp("Invalid smoothing coefficient C $coeff\n"); |
22
|
2
|
|
|
|
|
72
|
return; |
23
|
|
|
|
|
|
|
} |
24
|
14
|
100
|
|
|
|
34
|
if ( @$ra_data < 2 ) |
25
|
|
|
|
|
|
|
{ |
26
|
1
|
|
|
|
|
77
|
carp("Need at least 2 samples to smooth the data\n"); |
27
|
1
|
|
|
|
|
24
|
return; |
28
|
|
|
|
|
|
|
} |
29
|
13
|
|
|
|
|
35
|
$method = ucfirst( lc($method) ); |
30
|
13
|
|
|
|
|
33
|
my $sub_class = __PACKAGE__ . "::$method"; |
31
|
|
|
|
|
|
|
## no critic |
32
|
13
|
|
|
|
|
627
|
eval "require $sub_class"; |
33
|
|
|
|
|
|
|
## use critic |
34
|
13
|
100
|
|
|
|
63
|
die "No such class $sub_class: $@" if $@; |
35
|
|
|
|
|
|
|
|
36
|
12
|
|
|
|
|
85
|
return $sub_class->_new( |
37
|
|
|
|
|
|
|
{ |
38
|
|
|
|
|
|
|
data => $ra_data, |
39
|
|
|
|
|
|
|
samples => $ra_samples, |
40
|
|
|
|
|
|
|
count => scalar @$ra_data, |
41
|
|
|
|
|
|
|
coeff => $coeff, |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
145
|
|
|
145
|
1
|
1026
|
sub get_smoothing_coeff { $_[0]->{coeff} } |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub set_smoothing_coeff |
49
|
|
|
|
|
|
|
{ |
50
|
2
|
|
|
2
|
1
|
6
|
my ( $self, $coeff ) = @_; |
51
|
|
|
|
|
|
|
|
52
|
2
|
100
|
66
|
|
|
10
|
if ( $coeff < 0 || $coeff > 1 ) |
53
|
|
|
|
|
|
|
{ |
54
|
1
|
|
|
|
|
68
|
carp("Invalid smoothing coefficient C $coeff\n"); |
55
|
1
|
|
|
|
|
33
|
return; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
2
|
$self->{coeff} = $coeff; |
59
|
1
|
|
|
|
|
2
|
return 1; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |