Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Randomly biased, random numbers.

by RichardK (Priest)
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.
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.

Log In?
Username:
Password:

What's my password?
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 wandering the Monastery: (9)
As of 2014-12-26 15:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (171 votes), past polls