Sounds like you want to a number of distributions, from "one big clump" to "almost uniform", at random.
What about generating several "poles" as clump attractors, each with a random weight for attractiveness. Then let each point "roll" down hill according to the attractor weights and distances. So generate 3D coordinates, and use the extra value as the weight. Something like this:
for my $trial (1..$max_trials) {
my @attractors;
for my $attractors (1..int(rand($max_attractor))+1) {
my @attractor = get_random_tuple(3,\@attractor_limits);
push @attractors, \@attractor;
}
my @grid_points;
for my $points ($min_points..$max_points) {
my @point = get_random_tuple(2,@grid_point_limits);
# $alpha limits the distance moved downhill, and could be rand
+om
@point = roll_down_hill(\@point, \@attractors, $alpha);
push @grid_points, \@point;
}
my $result = analyze_data(\@grid_points);
}
sub get_random_tuple {
my $size_of_tuple = shift;
my $limits_ref = shift;
my @tuple;
for my $limit (@$limits_ref) {
push @tuple, rand($limit);
}
return @tuple;
}
sub roll_down_hill {
# left as an exercise for OMAR!
}
You can also play with variations of roll_down_hill to try different distributions, going from sub-linear to exponential (or maybe some of each), trying a host of different functions for transformations. And don't forget you can play with the distributions wherever you take a random number, including the number of attractors and their weights. For instance, you might find that fewer attractors are more likely to cause worst case behavior, and bias the number of attractors in the small direction.
-QM
--
Quantum Mechanics: The dreams stuff is made of
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.