blib/lib/App/RecordStream/Aggregator/Correlation.pm

filter: Statementstmt 96.7% 30 / 31 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 3 totaltotal 88.3% 38 / 43 CC 1 SCAR 1.1
CC
1
Cov
97%
long_usage
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« blib/lib/App/RecordStream/Aggregator/Variance.pm ↑ Summary blib/lib/App/RecordStream/Aggregator/Covariance.pm »
1 package App::RecordStream::Aggregator::Correlation;
2  
3 7 our $VERSION = "4.0.23";
4  
5 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 ▶use App::RecordStream::Aggregator::Ord2Bivariate;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 7 ▶use App::RecordStream::Aggregator;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 ▶use App::RecordStream::DomainLanguage::Registry;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 7 ▶use base 'App::RecordStream::Aggregator::Ord2Bivariate';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 #sub new -- passed through
15  
16 #sub new_from_valuation -- passed through
17  
18 sub squish
19 {
20 2 ▶ my ($this, $cookie) = @_;
Subroutine squish: called CC=1 SCAR=0.0
Pod undocumented
21  
22 2 my ($sum1, $sumx, $sumy, $sumxy, $sumx2, $sumy2) = @$cookie;
23  
24 2 return ($sumxy * $sum1 - $sumx * $sumy) / sqrt(($sumx2 * $sum1 - $sumx ** 2) * ($sumy2 * $sum1 - $sumy ** 2));
25 }
26  
27 sub long_usage
28 {
29 return <<EOF
30 Usage: corr,<field1>,<field2>
31 Correlation of specified fields.
32  
33 This is Cov(X, Y) / sqrt(Var(X) * Var(Y)). See help on aggregators cov and var
34 for how Cov(...) and Var(...) are computed. Ultimately this value is in [-1,
35 1] where larger negative values indicate larger inverse correlation and larger
36 positive values indicate larger positive correlation.
37 EOF
38 0 ▶}
Subroutine long_usage: not called CC=1 SCAR=6.9
Pod undocumented
39  
40 sub short_usage
41 {
42 1 ▶ return "find correlation of provided fields";
Subroutine short_usage: called CC=1 SCAR=0.0
Pod undocumented
43 }
44  
45 7 App::RecordStream::Aggregator->register_implementation('corr', __PACKAGE__);
46 7 App::RecordStream::Aggregator->register_implementation('correl', __PACKAGE__);
47 7 App::RecordStream::Aggregator->register_implementation('correlation', __PACKAGE__);
48  
49 7 App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'corr', 'VALUATION', 'VALUATION');
50 7 App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'correl', 'VALUATION', 'VALUATION');
51 7 App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'correlation', 'VALUATION', 'VALUATION');
52  
53 7 1;
« blib/lib/App/RecordStream/Aggregator/Variance.pm ↑ Summary blib/lib/App/RecordStream/Aggregator/Covariance.pm »