Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Rand() with ?log10? distribution?

by BrowserUk (Pope)
on Jun 07, 2013 at 05:47 UTC ( #1037582=note: print w/replies, xml ) Need Help??


in reply to Re: Rand() with ?log10? distribution?
in thread Rand() with ?log10? distribution?

We have a winner! sub primo2{ int( rand() ** 4 * $_[0] ) } Thanks.

I came up with a few of my own:

sub xx2{ int( 2**( 2**( rand() * logN( $_[0], 2 ) ) ) ) } sub xx10{ int( 10**( 10**( rand() * logN( $_[0], 10 ) ) ) ) } sub xx20{ int( 20**( 20**( rand() * logN( $_[0], 20 ) ) ) ) } sub xx100{ int( 100**( 100**( rand() * logN( $_[0], 100 ) ) ) ) }

which I actually prefer to your original because they drop faster at the beginning but don't dip so low at the end, but they are computationally expensive and require the upper limited supplied as a log.

Then I tried varying the exponent on yours, and found its ease of tunability the winning feature. Many thanks.

graph (The above 4 are red, blue, green and cyan respectively, your original(^2) is magenta, and my chosen variation on it (^4) is yellow.)


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://1037582]
help
Chatterbox?
[marinersk]: I appear to be unusually dependent on spacial stability. I have had trouble from someone moving an object a mere four inches to the left.
[Eily]: I think the solution is to write posts so brilliant that you gain XP on each refresh, no matter how often :P
[marinersk]: Eily++ and LOL
[marinersk]: I get a lighter version of this disconcertion (new word?) when the n points remaining until rank disappears.
[choroba]: :-D
[marinersk]: I've often marvelled over the past few decades at just how little it takes to mess me up with this spacial dependence thing. I wonder if I'm mildly autistic or something.

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2017-05-29 13:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?