Math::LogRand - Perl extension to return a random number with log weighting.
use Math::LogRand; my %test; my $min = 20; my $max = 100; $test{ LogRand($min,$max) }++ for 0..1000; print "$_\toccured $test{$_} times.\n" foreach sort keys %test;
This module attempts to implement a scalar version of the MATLAB logrand function.
Accepts two arguments: the floor of distribution, and the ceilling of distribution.
Returns a 'random' integer produced by the Perl rand() function, between input parameters, with weighting to low integers by log distribution.
rand()
How good/bad this is, I don't know: it's really for my own convenience, but I hope you find it useful. Any suggestions really very gratefully received!
LogRand
Lee Goddard <lgoddard(a)cpan.org>
perl(1); rand; log;
To install Math::LogRand, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::LogRand
CPAN shell
perl -MCPAN -e shell install Math::LogRand
For more information on module installation, please visit the detailed CPAN module installation guide.