I also need something like that, but what I want to do is
a little bit more complicated. I need to generate random
numbers using the standard distribution, that is, I want the
numbers in the middle to have a higher frequency than the
others.
UPDATE
After talking with you I found that you have two rather
irritating conditions. You cannot easily install modules,
and you want to skew the output. Here is some sample code
that gives you an idea how to do that, but I am warning
you that it will take a lot of playing around to get this
to produce what you want...
my @weights = qw(0.5 1 2);
my @random = sort {$a <=> $b} map{rand()} 0..$#weights;
my $tot;
foreach (0..$#weights) {
$tot += $random[$_] * $weights[$_];
}
print $tot;