File Coverage

blib/lib/App/RecordStream/Aggregator/Variance.pm
Criterion Covered Total %
statement 21 23 91.3
branch n/a
condition n/a
subroutine 7 9 77.7
pod 0 3 0.0
total 28 35 80.0


line stmt bran cond sub pod time code
1             package App::RecordStream::Aggregator::Variance;
2              
3             our $VERSION = "4.0.25";
4              
5 6     6   81422 use strict;
  6         19  
  6         143  
6 6     6   25 use warnings;
  6         9  
  6         143  
7              
8 6     6   2268 use App::RecordStream::Aggregator::Ord2Univariate;
  6         18  
  6         157  
9 6     6   31 use App::RecordStream::Aggregator;
  6         14  
  6         82  
10 6     6   471 use App::RecordStream::DomainLanguage::Registry;
  6         10  
  6         116  
11              
12 6     6   25 use base 'App::RecordStream::Aggregator::Ord2Univariate';
  6         13  
  6         1172  
13              
14             #sub new -- passed through
15              
16             #sub new_from_valuation -- passed through
17              
18             sub squish
19             {
20 1     1 0 11 my ($this, $cookie) = @_;
21              
22 1         4 my ($sum1, $sumx, $sumx2) = @$cookie;
23              
24 1         9 return ($sumx2 / $sum1) - ($sumx / $sum1) ** 2;
25             }
26              
27             sub long_usage
28             {
29 0     0 0   return <
30             Usage: var,
31             Variance of specified fields.
32              
33             This is computed as Var(X) = E[(X - E[X])^2]. Variance is an indication of
34             deviation from average value.
35             EOF
36             }
37              
38             sub short_usage
39             {
40 0     0 0   return "find variance of provided field";
41             }
42              
43             App::RecordStream::Aggregator->register_implementation('var', __PACKAGE__);
44             App::RecordStream::Aggregator->register_implementation('variance', __PACKAGE__);
45              
46             App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'var', 'VALUATION');
47             App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'variance', 'VALUATION');
48              
49             1;