File Coverage

blib/lib/App/RecordStream/Aggregator/Covariance.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::Covariance;
2              
3             our $VERSION = "4.0.24";
4              
5 6     6   56645 use strict;
  6         15  
  6         154  
6 6     6   29 use warnings;
  6         15  
  6         161  
7              
8 6     6   1594 use App::RecordStream::Aggregator::Ord2Bivariate;
  6         17  
  6         141  
9 6     6   37 use App::RecordStream::Aggregator;
  6         17  
  6         109  
10 6     6   302 use App::RecordStream::DomainLanguage::Registry;
  6         16  
  6         139  
11              
12 6     6   34 use base 'App::RecordStream::Aggregator::Ord2Bivariate';
  6         12  
  6         1208  
13              
14             #sub new -- passed through
15              
16             #sub new_from_valuation -- passed through
17              
18             sub squish
19             {
20 10     10 0 39 my ($this, $cookie) = @_;
21              
22 10         27 my ($sum1, $sumx, $sumy, $sumxy, $sumx2, $sumy2) = @$cookie;
23              
24 10         69 return ($sumxy / $sum1) - ($sumx / $sum1) * ($sumy / $sum1);
25             }
26              
27             sub long_usage
28             {
29 0     0 0   return <
30             Usage: cov,,
31             Covariance of specified fields.
32             EOF
33             }
34              
35             sub short_usage
36             {
37 0     0 0   return "find covariance of provided fields";
38             }
39              
40             App::RecordStream::Aggregator->register_implementation('cov', __PACKAGE__);
41             App::RecordStream::Aggregator->register_implementation('covar', __PACKAGE__);
42             App::RecordStream::Aggregator->register_implementation('covariance', __PACKAGE__);
43              
44             App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'cov', 'VALUATION', 'VALUATION');
45             App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'covar', 'VALUATION', 'VALUATION');
46             App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'covariance', 'VALUATION', 'VALUATION');
47              
48             1;