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.0302'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
673
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
9
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
165
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
2
|
|
|
2
|
1
|
1633
|
my $class = shift; |
15
|
2
|
|
|
|
|
8
|
my %args = @_; |
16
|
|
|
|
|
|
|
my $self = { |
17
|
|
|
|
|
|
|
top => $args{top} || 1, |
18
|
2
|
|
50
|
|
|
11
|
n => $args{n} || 2, |
|
|
|
50
|
|
|
|
|
19
|
|
|
|
|
|
|
}; |
20
|
2
|
|
|
|
|
4
|
bless $self, $class; |
21
|
2
|
|
|
|
|
11
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub choose { |
26
|
2
|
|
|
2
|
1
|
356
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
4
|
my @distribution; |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
5
|
my $top = $self->{top}; |
31
|
2
|
|
|
|
|
4
|
my $n = $self->{n}; |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
6
|
for my $i ( 1 .. $n ) { |
34
|
7
|
|
|
|
|
43
|
my $curr = rand($top); |
35
|
7
|
|
|
|
|
12
|
my $next = abs( $top - $curr ); |
36
|
|
|
|
|
|
|
|
37
|
7
|
100
|
|
|
|
15
|
push @distribution, $i == $n ? $top : $next; |
38
|
|
|
|
|
|
|
|
39
|
7
|
|
|
|
|
14
|
$top = $curr; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
2
|
|
|
|
|
7
|
return \@distribution; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |