File Coverage

blib/lib/Statistics/Basic/StdDev.pm
Criterion Covered Total %
statement 32 32 100.0
branch 5 10 50.0
condition n/a
subroutine 7 7 100.0
pod 2 2 100.0
total 46 51 90.2


line stmt bran cond sub pod time code
1              
2             package Statistics::Basic::StdDev;
3              
4 33     33   134 use strict;
  33         42  
  33         1315  
5 33     33   141 use warnings;
  33         39  
  33         713  
6 33     33   148 use Carp;
  33         50  
  33         1851  
7              
8 33     33   198 use base 'Statistics::Basic::_OneVectorBase';
  33         47  
  33         9881  
9              
10             sub new {
11 36     36 1 1255 my $class = shift;
12              
13 36 50       85 warn "[new $class]\n" if $Statistics::Basic::DEBUG >= 2;
14              
15 36         89 my $this = bless {}, $class;
16 36 50       42 my $variance = $this->{V} = eval { Statistics::Basic::Variance->new(@_) } or croak $@;
  36         257  
17 36         137 my $vector = $this->{v} = $variance->query_vector;
18 36 50       89 my $c = $vector->_get_computer( 'stddev' ); return $c if defined $c;
  36         97  
19              
20 36         88 $vector->_set_computer( stddev => $this );
21              
22 36         550 return $this;
23             }
24              
25             sub _recalc {
26 53     53   63 my $this = shift;
27 53         60 my $first = shift;
28              
29 53         83 delete $this->{recalc_needed};
30              
31 53         216 my $var = $this->{V}->query;
32 53 50       102 return unless defined $var;
33             # no need to query filled here, variance does it for us
34              
35 53 50       92 warn "[recalc " . ref($this) . "] sqrt( $var )\n" if $Statistics::Basic::DEBUG;
36              
37 53         111 $this->{_value} = sqrt( $var );
38              
39 53         5867 return;
40             }
41              
42             sub query_mean {
43 1     1 1 4 my $this = shift;
44              
45 1         4 return $this->{V}->query_mean;
46             }
47              
48             1;