Subscribe to DSC Newsletter

Very short and simple source code to produce nice simulated cluster structures (stored in a text file called cluster.txt) and test cluster detection algorithms. The version below is written in Perl, and here's an example of output with 3 simulated clusters:

`rm cluster.txt`;

$cluster=0;
&seed(1,1);
$cluster++;
&seed(-5,-5);
$cluster++;
&seed(0,0);


#--------------------------------------------------------------------
sub seed {

local($x,$y)=@_;
$kmax=rand(300);
$x=rand($x)-0.5;
$y=rand($y)-0.5;
#print "==$x == $y\n";

for ($k=0; $k<$kmax; $k++) {
$x=$x+rand($1)-0.5;
$y=$y+rand($1)-0.5;
$px[$k]=$x;
$py[$k]=$y;
}

open(OUT,">>cluster.txt");
for ($k=0; $k<$kmax; $k++) {
print OUT "$cluster\t$px[$k]\t$py[$k]\n";
}
close(OUT);

}

Views: 2790

Replies to This Discussion

Similar code in PHP attached to this comment.

Attachments:

RSS

Follow Us

On Data Science Central

On DataViz

On Hadoop

¬© 2017   AnalyticBridge.com is a subsidiary and dedicated channel of Data Science Central LLC   Powered by

Badges  |  Report an Issue  |  Terms of Service