line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::Partition::Rand; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:GENE'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# ABSTRACT: Random floating point additive partitions |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.0301'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
630
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
9
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
174
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
1
|
|
|
1
|
1
|
304
|
my $class = shift; |
15
|
1
|
|
|
|
|
3
|
my %args = @_; |
16
|
|
|
|
|
|
|
my $self = { |
17
|
|
|
|
|
|
|
top => $args{top} || 1, |
18
|
1
|
|
50
|
|
|
5
|
n => $args{n} || 2, |
|
|
|
50
|
|
|
|
|
19
|
|
|
|
|
|
|
}; |
20
|
1
|
|
|
|
|
2
|
bless $self, $class; |
21
|
1
|
|
|
|
|
2
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub choose { |
26
|
1
|
|
|
1
|
1
|
245
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
1
|
my @distribution; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
1
|
my $label = 0; |
31
|
1
|
|
|
|
|
4
|
my $top = $self->{top}; |
32
|
1
|
|
|
|
|
1
|
my $n = $self->{n}; |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
3
|
for my $i ( 1 .. $n ) { |
35
|
3
|
|
|
|
|
30
|
my $curr = rand($top); |
36
|
3
|
|
|
|
|
2
|
my $next = abs( $top - $curr ); |
37
|
|
|
|
|
|
|
|
38
|
3
|
100
|
|
|
|
7
|
push @distribution, $i == $n ? $top : $next; |
39
|
|
|
|
|
|
|
|
40
|
3
|
|
|
|
|
2
|
$top = $curr; |
41
|
3
|
|
|
|
|
4
|
$label++; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
3
|
return \@distribution; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |