line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
839
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Math::Random::GaussianRange; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#ABSTRACT: Given a range, generate a set of random numbers normally distributed. |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1028
|
use Math::Random qw(random_normal); |
|
1
|
|
|
|
|
12828
|
|
|
1
|
|
|
|
|
92
|
|
9
|
1
|
|
|
1
|
|
788
|
use Statistics::Basic qw(median); |
|
1
|
|
|
|
|
20248
|
|
|
1
|
|
|
|
|
5
|
|
10
|
1
|
|
|
1
|
|
21311
|
use Carp; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
54
|
|
11
|
1
|
|
|
1
|
|
5
|
use base 'Exporter'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
287
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT = 'generate_normal_range'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub generate_normal_range { |
17
|
6
|
|
|
6
|
1
|
4221
|
my $rh = shift; |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
|
|
|
9
|
my $min = $rh->{min}; |
20
|
6
|
|
|
|
|
8
|
my $max = $rh->{max}; |
21
|
6
|
|
50
|
|
|
19
|
my $n = $rh->{n} || 100; |
22
|
6
|
|
100
|
|
|
24
|
my $round = $rh->{round} || 0; |
23
|
|
|
|
|
|
|
|
24
|
6
|
100
|
100
|
|
|
22
|
unless ( defined $min && defined $max ) { |
25
|
2
|
|
|
|
|
16
|
croak "Specify a range using the min and max parameters."; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
4
|
100
|
|
|
|
8
|
if ( $min > $max ) { |
29
|
1
|
|
|
|
|
22
|
croak "The minimum cannot exceeed the maximum"; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
3
|
|
|
|
|
221
|
my @range = ( $min .. $max ); |
33
|
3
|
|
|
|
|
71
|
my $median = median( @range ); |
34
|
3
|
|
|
|
|
952
|
my $sd = $median/3; |
35
|
|
|
|
|
|
|
|
36
|
3
|
100
|
66
|
|
|
1204
|
if ( $median == 0 || $sd == 0 ) { |
37
|
1
|
|
|
|
|
16
|
croak "Median and SD are both null."; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
105
|
my @output = |
41
|
|
|
|
|
|
|
random_normal( $n, $median, $sd ); |
42
|
|
|
|
|
|
|
|
43
|
2
|
100
|
66
|
|
|
1642
|
if ( defined $round && $round > 0) { |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
2
|
my $ra_rounded = [ ]; |
46
|
1
|
|
|
|
|
2
|
foreach my $i ( @output ) { |
47
|
100
|
|
|
|
|
125
|
push( @$ra_rounded, sprintf('%.0f', $i) ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
33
|
return $ra_rounded; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
55
|
return \@output; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |