Stem-and-leaf plot/Data generator: Difference between revisions
Content added Content deleted
(Should produce a bell curve distribution for each hump, now.) |
No edit summary |
||
Line 15: | Line 15: | ||
sub genhump |
sub genhump |
||
{ |
{ |
||
my $offset = |
my ($offset, $width, $pointcount, $slope) = @_; |
||
my $width = shift; |
|||
my $pointcount = shift; |
|||
my $slope = shift; |
|||
my $diecount = $slope; |
my $diecount = $slope; |
||
Line 24: | Line 21: | ||
my @ret; |
my @ret; |
||
foreach (1 .. $pointcount) |
|||
while($pointcount-- > 0) |
|||
{ |
{ |
||
my $point = $offset; |
my $point = $offset; |
||
foreach (1 .. $diecount) |
|||
{ |
{ |
||
$point += rand($range * 10000) / 10000; |
$point += rand($range * 10000) / 10000; |
||
Line 38: | Line 35: | ||
} |
} |
||
my @list = () |
my @list = (&genhump(8, 3, 5, 3), |
||
⚫ | |||
push @list, &genhump(8, 3, 5, 3); |
|||
⚫ | |||
my @shuffled = &shuffle(@list); |
my @shuffled = &shuffle(@list); |
||
print " |
print "@shuffled\n";</lang> |
||
foreach ( @shuffled ); |
|||
</lang> |