Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: custom random number generator

by toro (Beadle)
on Nov 30, 2011 at 07:24 UTC ( #940787=note: print w/ replies, xml ) Need Help??


in reply to custom random number generator

Anonymous Monk, you could

  1. do your bell curve trick to produce a standard normal ∈ (−∞, +∞) centred on 0
  2. map the negative half (−∞, 0] thru exp onto 0,1 and thence thru ƒ($num) = x over {1 + y • (1 − $num)} onto [x/y, x].
  3. map the positive half (0, +∞) thru g($rand) = 1−exp(−$rand) onto (0,1) and thence thru h($num) = x • (1 + $num • y) onto (x, xy).
. That will be centred on x, mound-shaped, and put half the probability mass on either side of x — stretched according to your whims.


Comment on Re: custom random number generator
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://940787]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2015-07-30 02:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls