BrowserUk:

Here's another idea that occurred to me, so I thought I'd toss it out--build a function that generates a coordinate and then randomly maps it into a "clump" for you. In order to prevent any of your area from being ignored, there's also a chance that it won't be mapped to a clump:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; sub generate_clumpy_rand { my $num = shift // int(10*rand()+3); my @clumps; print "Generator has $num clumps\n"; for my $i (1 .. $num) { my @center_size = (rand, rand, rand, rand); print "clump 1 centered at ($center_size[0],$center_size[1]) " . "size is $center_size[2]x$center_size[3]\n"; push @clumps, \@center_size; } return sub { my @coord = (rand, rand); # Ensure we have a background of random dots over entire regio +n return @coord if (.1 > rand); # Choose a clump, and map the coordinate into that clump my @clump = @{$clumps[rand @clumps]}; return ( ($coord[0]*$clump[2])+$clump[0], ($coord[1]*$clump[3])+$clump[1] ); } } my $clump_rand = generate_clumpy_rand(1); my @coord = $clumpy_rand->(); print Dumper(\@coord);

The good point is that it's simple and fast. It's a proof-of-concept, though, and I didn't do any work to ensure that the clumps don't extend beyond the desired range. If you like the idea, then that task is left as an exercise for the reader ;^D.

Update: I forgot to mention: The clumps in this version are rectangular. Changing their shape is possible, but I didn't bother doing that, either.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re: Randomly biased, random numbers. by roboticus
in thread Randomly biased, random numbers. by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.