Stem-and-leaf plot/Data generator: Difference between revisions

A note about variable names.
(Should produce a bell curve distribution for each hump, now.)
(A note about variable names.)
 
(One intermediate revision by one other user not shown)
Line 1:
Written to generate data sets for the [[Stem-and-leaf plot]] task. Statistics aren't my field or area of significant expertise, so some of the variable names might represent my homebrew understanding more than official terminology. --[[User:Short Circuit|Michael Mol]] 19:34, 14 December 2009 (UTC)
 
<lang perl>#!/usr/bin/perl
Line 15:
sub genhump
{
my ($offset, $width, $pointcount, $slope) = shift@_;
my $width = shift;
my $pointcount = shift;
my $slope = shift;
 
my $diecount = $slope;
Line 24 ⟶ 21:
 
my @ret;
foreach (1 .. $pointcount)
while($pointcount-- > 0)
{
my $point = $offset;
forforeach (my1 $roll = 0; $roll <.. $diecount; ++$roll)
{
$point += rand($range * 10000) / 10000;
Line 38 ⟶ 35:
}
 
my @list = (&genhump(8, 3, 5, 3);,
push @list, &genhump(12, 3, 5, 6));
 
push @list, &genhump(8, 3, 5, 3);
push @list, &genhump(12, 3, 5, 6);
 
my @shuffled = &shuffle(@list);
 
print "$_ @shuffled\n";</lang>
foreach ( @shuffled );
</lang>