File Coverage

blib/lib/Math/Random/LogUniform.pm
Criterion Covered Total %
statement 12 16 75.0
branch n/a
condition n/a
subroutine 4 6 66.6
pod 2 2 100.0
total 18 24 75.0


line stmt bran cond sub pod time code
1             package Math::Random::LogUniform;
2              
3 1     1   378108 use strict;
  1         3  
  1         71  
4 1     1   7 use warnings;
  1         2  
  1         87  
5              
6 1     1   7 use Exporter qw(import);
  1         7  
  1         48  
7 1     1   15402 use POSIX qw(floor);
  1         10992  
  1         7  
8              
9             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
10             our $DATE = '2023-12-28'; # DATE
11             our $DIST = 'Math-Random-LogUniform'; # DIST
12             our $VERSION = '0.001'; # VERSION
13              
14             our @EXPORT_OK = qw(logrand);
15              
16             sub logrand {
17 0     0 1   my ($min, $max) = @_;
18              
19 0           exp(log($min) + rand()*(log($max) - log($min)));
20             }
21              
22             sub logirand {
23 0     0 1   my ($min, $max) = @_;
24              
25 0           floor(exp(log($min) + rand()*(log($max) - log($min))));
26             }
27              
28             1;
29             # ABSTRACT: Generate log-uniform random numbers
30              
31             __END__