Welcome to the Monastery PerlMonks

### Re: Randomly biased, random numbers.

by RichardK (Parson)
 on Dec 05, 2013 at 23:05 UTC ( #1065861=note: print w/ replies, xml ) Need Help??

in reply to Randomly biased, random numbers.

I think it might be worth trying polar coordinates, so that each new point is a random distance and direction form the last. Then you can tweak your distance distributions to suit your purpose. If you need to restrict the total area, you could wrap the 2d space or just ignore any points that fall outside.

Math::Trig has handy polar conversion functions, so it would be easy to give it a try.

Comment on Re: Randomly biased, random numbers.
Replies are listed 'Best First'.
Re^2: Randomly biased, random numbers.
by BrowserUk (Pope) on Dec 06, 2013 at 00:46 UTC

Nice thought. I tried this and several variations on it:

```my \$start = [ int( rand 500 ), int( rand 500 ) ];
my @points = map{
my \$a = rand( 2*PI );
my \$d = int( rand 500 );
my \$x = \$d * cos( \$a );
my \$y = \$d * sin( \$a );
\$x -= 500 while \$x > 500;
\$x += 500 while \$x < 0;
\$y -= 500 while \$y > 500;
\$y += 500 while \$y < 0;
[ \$x, \$y ];
} 1 .. \$N;

Whilst it certainly tends to create clusters, the clusters tend to be (very) evenly distributed, which doesn't trigger the worse case.

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.

How about using a inverse log distance distribution? Maybe something like this :-

```my \$d = max_distance * ( 1 - log( rand(1000) ) / log( 1000 ) );

See Re^2: Randomly biased, random numbers. for a similar type of mapping function and why its not suitable.

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.

Create A New User
Node Status?
node history
Node Type: note [id://1065861]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (16)
As of 2016-05-24 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
What font do you use for programming?

Results (314 votes). Check out past polls.