| 1 | package Math::Histo::KDE; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Math::Histo (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Math::Histo::Constants (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||
| 8 | 1 | our $VERSION = '0.4.0'; | |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||
| 10 | 1 | my %KERNEL_MAP = ( | |||||||||||||||||||||||||||||||||
| 11 | gaussian => Math::Histo::Constants::HISTO_KDE_KERNEL_GAUSSIAN, | ||||||||||||||||||||||||||||||||||
| 12 | epanechnikov => Math::Histo::Constants::HISTO_KDE_KERNEL_EPANECHNIKOV, | ||||||||||||||||||||||||||||||||||
| 13 | uniform => Math::Histo::Constants::HISTO_KDE_KERNEL_UNIFORM, | ||||||||||||||||||||||||||||||||||
| 14 | boxcar => Math::Histo::Constants::HISTO_KDE_KERNEL_UNIFORM, | ||||||||||||||||||||||||||||||||||
| 15 | triangular => Math::Histo::Constants::HISTO_KDE_KERNEL_TRIANGULAR, | ||||||||||||||||||||||||||||||||||
| 16 | biweight => Math::Histo::Constants::HISTO_KDE_KERNEL_BIWEIGHT, | ||||||||||||||||||||||||||||||||||
| 17 | quartic => Math::Histo::Constants::HISTO_KDE_KERNEL_BIWEIGHT, | ||||||||||||||||||||||||||||||||||
| 18 | cosine => Math::Histo::Constants::HISTO_KDE_KERNEL_COSINE, | ||||||||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||
| 21 | 1 | my %BW_MAP = ( | |||||||||||||||||||||||||||||||||
| 22 | silverman => Math::Histo::Constants::HISTO_KDE_BW_SILVERMAN, | ||||||||||||||||||||||||||||||||||
| 23 | scott => Math::Histo::Constants::HISTO_KDE_BW_SCOTT, | ||||||||||||||||||||||||||||||||||
| 24 | manual => Math::Histo::Constants::HISTO_KDE_BW_MANUAL, | ||||||||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||
| 27 | sub new { | ||||||||||||||||||||||||||||||||||
| 28 | 7 | ▶ | my ($class, %args) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=24.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 29 | 7 | ▶ | my $samples = $args{samples} // $args{data} // croak("Math::Histo::KDE->new: 'samples' arrayref required"); | ||||||||||||||||||||||||||||||||
|
Condition33%2/6
($args{"samples"} // $args{"data"}) // croak("Math::Histo::KDE->new: 'samples' arrayref required")
$args{"samples"} // $args{"data"}
MC/DC0%0/3
($args{"samples"} // $args{"data"}) // croak("Math::Histo::KDE->new: 'samples' arrayref required")
$args{"samples"}
$args{"data"}
croak("Math::Histo::KDE->new: 'samples' arrayref required")
Truth table25%1/4
A // B // C
A= $args{"samples"}B= $args{"data"}C= croak("Math::Histo::KDE->new: 'samples' arrayref required")
| |||||||||||||||||||||||||||||||||||
| 30 | 7 | my $weights = $args{weights}; | |||||||||||||||||||||||||||||||||
| 31 | 7 | ▶ | my $kernel = $args{kernel} // 'gaussian'; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"kernel"} // "gaussian"
MC/DC0%0/1
$args{"kernel"} // "gaussian"
$args{"kernel"}
Truth table50%1/2
A
A= $args{"kernel"}
| |||||||||||||||||||||||||||||||||||
| 32 | 7 | ▶ | my $bw_method = $args{bw_method} // 'silverman'; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"bw_method"} // "silverman"
MC/DC0%0/1
$args{"bw_method"} // "silverman"
$args{"bw_method"}
Truth table50%1/2
A
A= $args{"bw_method"}
| |||||||||||||||||||||||||||||||||||
| 33 | 7 | ▶ | my $bandwidth = $args{bandwidth} // 0.0; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"bandwidth"} // 0
MC/DC100%1/1
$args{"bandwidth"} // 0
$args{"bandwidth"}
Truth table100%2/2
A
A= $args{"bandwidth"}
| |||||||||||||||||||||||||||||||||||
| 34 | 7 | ▶ | my $bw_adjust = $args{bw_adjust} // 1.0; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"bw_adjust"} // 1
MC/DC0%0/1
$args{"bw_adjust"} // 1
$args{"bw_adjust"}
Truth table50%1/2
A
A= $args{"bw_adjust"}
| |||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||
| 36 | 7 | ▶ | my $k_code = exists $KERNEL_MAP{lc($kernel)} ? $KERNEL_MAP{lc($kernel)} : int($kernel); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 37 | 7 | ▶ | my $bw_code = exists $BW_MAP{lc($bw_method)} ? $BW_MAP{lc($bw_method)} : int($bw_method); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||
| 39 | 7 | return $class->_create($samples, $weights, $k_code, $bw_code, $bandwidth, $bw_adjust); | |||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||
| 42 | sub from_histogram { | ||||||||||||||||||||||||||||||||||
| 43 | 1 | ▶ | my ($class, $h, %args) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
from_histogram: called CC=7 SCAR=21.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | my $kernel = $args{kernel} // 'gaussian'; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"kernel"} // "gaussian"
MC/DC0%0/1
$args{"kernel"} // "gaussian"
$args{"kernel"}
Truth table50%1/2
A
A= $args{"kernel"}
| |||||||||||||||||||||||||||||||||||
| 45 | 1 | ▶ | my $bw_method = $args{bw_method} // 'silverman'; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"bw_method"} // "silverman"
MC/DC0%0/1
$args{"bw_method"} // "silverman"
$args{"bw_method"}
Truth table50%1/2
A
A= $args{"bw_method"}
| |||||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | my $bandwidth = $args{bandwidth} // 0.0; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"bandwidth"} // 0
MC/DC0%0/1
$args{"bandwidth"} // 0
$args{"bandwidth"}
Truth table50%1/2
A
A= $args{"bandwidth"}
| |||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | my $bw_adjust = $args{bw_adjust} // 1.0; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"bw_adjust"} // 1
MC/DC0%0/1
$args{"bw_adjust"} // 1
$args{"bw_adjust"}
Truth table50%1/2
A
A= $args{"bw_adjust"}
| |||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||
| 49 | 1 | ▶ | my $k_code = exists $KERNEL_MAP{lc($kernel)} ? $KERNEL_MAP{lc($kernel)} : int($kernel); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 50 | 1 | ▶ | my $bw_code = exists $BW_MAP{lc($bw_method)} ? $BW_MAP{lc($bw_method)} : int($bw_method); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||
| 52 | 1 | return $class->_create_from_histo($h, $k_code, $bw_code, $bandwidth, $bw_adjust); | |||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||
| 55 | sub pdf { | ||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | my ($self, $x) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
pdf: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 57 | 0 | return $self->eval($x); | |||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||
| 60 | 1 | 1; | |||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||
| 62 | __END__ | ||||||||||||||||||||||||||||||||||