Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Randomly biased, random numbers.

by RichardK (Parson)
on Dec 05, 2013 at 23:05 UTC ( [id://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.

Replies are listed 'Best First'.
Re^2: Randomly biased, random numbers.
by BrowserUk (Patriarch) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1065861]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-16 07:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found