my @data; push @data, rand 1 for 1..30; # for 30 numbers my $sum; $sum += $_ for @data; # calculate sum $sum = 100 / $sum; # ratio to ensure they sum to 100 $_ *= $sum for @data; # then scale them all
-- Randal L. Schwartz, Perl hacker
In reply to •Re: Randomly generating histograms
by merlyn
in thread Randomly generating histograms
by narse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |