line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Shannon::Entropy; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
136092
|
use 5.006; |
|
2
|
|
|
|
|
15
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
41
|
|
5
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
76
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
889
|
use Import::Export; |
|
2
|
|
|
|
|
34282
|
|
|
2
|
|
|
|
|
13
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
83
|
use base qw/Import::Export/; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
411
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.101111'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %EX = ( |
14
|
|
|
|
|
|
|
entropy => [qw/all/] |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub entropy { |
18
|
5
|
|
|
5
|
1
|
607
|
my ($entropy, $len, $p, %t) = (0, length($_[0])); |
19
|
5
|
|
|
|
|
68
|
$t{$_}++ foreach split '', $_[0]; |
20
|
5
|
|
|
|
|
20
|
foreach (values %t) { |
21
|
57
|
|
|
|
|
74
|
$p = $_/$len; |
22
|
57
|
|
|
|
|
88
|
$entropy -= $p * log $p; |
23
|
|
|
|
|
|
|
} |
24
|
5
|
|
|
|
|
47
|
return $entropy / log 2; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__END__ |