line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
29761
|
use 5.006; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
119
|
|
2
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
87
|
|
3
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
163
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Math::Random::OO::Uniform; |
6
|
|
|
|
|
|
|
# ABSTRACT: Generates random numbers from the uniform distribution |
7
|
|
|
|
|
|
|
our $VERSION = '0.22'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Required modules |
10
|
3
|
|
|
3
|
|
18
|
use Carp; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
198
|
|
11
|
3
|
|
|
3
|
|
3271
|
use Params::Validate ':all'; |
|
3
|
|
|
|
|
38133
|
|
|
3
|
|
|
|
|
806
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ISA |
14
|
3
|
|
|
3
|
|
27
|
use base qw( Class::Accessor::Fast ); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
3203
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
{ |
18
|
|
|
|
|
|
|
my $param_spec = { |
19
|
|
|
|
|
|
|
low => { type => SCALAR }, |
20
|
|
|
|
|
|
|
high => { type => SCALAR } |
21
|
|
|
|
|
|
|
}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( keys %$param_spec ); |
24
|
|
|
|
|
|
|
#__PACKAGE__->mk_ro_accessors( keys %$param_spec ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
9
|
|
|
9
|
1
|
2899
|
my $class = shift; |
28
|
9
|
100
|
|
|
|
46
|
my $self = bless {}, ref($class) ? ref($class) : $class; |
29
|
9
|
100
|
|
|
|
34
|
if ( @_ > 1 ) { |
|
|
100
|
|
|
|
|
|
30
|
4
|
|
|
|
|
23
|
my ( $low, $high ) = sort { $a <=> $b } @_[ 0, 1 ]; # DWIM |
|
4
|
|
|
|
|
13
|
|
31
|
4
|
|
|
|
|
14
|
$self->low($low); |
32
|
4
|
|
|
|
|
71
|
$self->high($high); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
elsif ( @_ == 1 ) { |
35
|
1
|
|
|
|
|
4
|
$self->low(0); |
36
|
1
|
|
|
|
|
8
|
$self->high( $_[0] ); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
4
|
|
|
|
|
17
|
$self->low(0); |
40
|
4
|
|
|
|
|
51
|
$self->high(0); |
41
|
|
|
|
|
|
|
} |
42
|
9
|
|
|
|
|
71
|
return $self; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub seed { |
48
|
14
|
|
|
14
|
1
|
4119
|
my $self = shift; |
49
|
14
|
|
|
|
|
41
|
srand( $_[0] ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub next { |
54
|
30
|
|
|
30
|
1
|
225
|
my ($self) = @_; |
55
|
30
|
|
|
|
|
73
|
my $rnd = rand( $self->high - $self->low ) + $self->low; |
56
|
30
|
|
|
|
|
497
|
return $rnd; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |