line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
65868
|
use 5.006; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
84
|
|
2
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
58
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
118
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Math::Random::OO::Bootstrap; |
6
|
|
|
|
|
|
|
# ABSTRACT: Generate random numbers with bootstrap resampling from a non-parametric distribution |
7
|
|
|
|
|
|
|
our $VERSION = '0.22'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Required modules |
10
|
2
|
|
|
2
|
|
10
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
151
|
|
11
|
2
|
|
|
2
|
|
1149
|
use Params::Validate 0.76 ':all'; |
|
2
|
|
|
|
|
13924
|
|
|
2
|
|
|
|
|
471
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ISA |
14
|
2
|
|
|
2
|
|
16
|
use base qw( Class::Accessor::Fast ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1537
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
{ |
18
|
|
|
|
|
|
|
my $param_spec = { |
19
|
|
|
|
|
|
|
data => { type => ARRAYREF }, |
20
|
|
|
|
|
|
|
size => { type => SCALAR } |
21
|
|
|
|
|
|
|
}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( keys %$param_spec ); |
24
|
|
|
|
|
|
|
#__PACKAGE__->mk_ro_accessors( keys %$param_spec ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
6
|
|
|
6
|
1
|
2329
|
my $class = shift; |
28
|
6
|
100
|
|
|
|
37
|
my $self = bless {}, ref($class) ? ref($class) : $class; |
29
|
6
|
100
|
|
|
|
430
|
if ( @_ == 0 ) { |
30
|
1
|
|
|
|
|
256
|
croak 'Math::Random::OO::Bootstrap->new() requires an argument'; |
31
|
|
|
|
|
|
|
} |
32
|
5
|
100
|
|
|
|
35
|
$self->data( ref $_[0] eq 'ARRAY' ? [ @{ $_[0] } ] : [@_] ); |
|
1
|
|
|
|
|
7
|
|
33
|
5
|
|
|
|
|
46
|
$self->size( scalar @{ $self->data } ); |
|
5
|
|
|
|
|
15
|
|
34
|
5
|
|
|
|
|
62
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub seed { |
40
|
6
|
|
|
6
|
1
|
2859
|
my $self = shift; |
41
|
6
|
|
|
|
|
21
|
srand( $_[0] ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub next { |
46
|
6
|
|
|
6
|
1
|
7
|
my ($self) = @_; |
47
|
6
|
|
|
|
|
19
|
my $rnd = int( rand( $self->size ) ); # index 0 to (size-1) |
48
|
6
|
|
|
|
|
112
|
return $self->data->[$rnd]; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |