in reply to Randomly biased, random numbers.

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.

Replies are listed 'Best First'.
Re^2: Randomly biased, random numbers.
by BrowserUk (Patriarch) on Dec 08, 2013 at 07:46 UTC

    That's essentially a variation on my "I could generate a point; generate a bunch around that point (using a subrange of the coordinate space, and then fully randomly add a few more, ".

    With a few tweaks to constrain the output to the range 0-1, that does produce definite clumps and some odd ones. the main problem with it is the hard edges to the clumps with no graceful transition.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.