Random number generation from functions

D

drs

Is there any way to generate random numbers based on arbitrary real valued
functions? I am looking for something like random.gauss() but with natural
log and exponential functions.

thanks,

-d
 
B

Bengt Richter

Is there any way to generate random numbers based on arbitrary real valued
functions? I am looking for something like random.gauss() but with natural
log and exponential functions.

thanks,
Don't know what you mean. This kind of thing?
(the 1-random... is to make the random numbers in (0,1] instead of [0,1))
-0.99694366818547997

Regards,
Bengt Richter
 
C

Colin J. Williams

drs said:
Is there any way to generate random numbers based on arbitrary real valued
functions? I am looking for something like random.gauss() but with natural
log and exponential functions.

thanks,

-d
numarray has a random package which provides a number of functions,
including: normal( mean, stddev, shape=[])

That may serve your need.

Colin W.
 
C

CptPicard

drs said:
Is there any way to generate random numbers based on arbitrary real valued
functions? I am looking for something like random.gauss() but with natural
log and exponential functions.

thanks,

-d
I remember for having used it on a gaussian generator that you can do that very
easily by yourself:
- you generate a random real number in the range [0 .. 1],
- then you apply an inverse probability density function (e.g. inverse gaussian
pdf : http://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/rigpdf.htm),
and you have then your random number following the specified law (here gaussian).
 
R

Robert Kern

drs said:
Is there any way to generate random numbers based on arbitrary real valued
functions? I am looking for something like random.gauss() but with natural
log and exponential functions.

scipy[1] has a large collection of "standard" univariate pdfs, including
normal, exponential, gamma, and the like.

One cannot generate random numbers from arbitrary real valued functions
because a function needs to satisfy certain restrictions to be a pdf.
For example, you cannot generate random numbers "with a log function",
unless you restrict the domain and renormalize.

Generating random numbers from an arbitrary pdf is possible, but tricky.
I encourage you to search the literature for "monte carlo sampling."

[1] http://www.scipy.org

--
Robert Kern
(e-mail address removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 
A

Alejandro López-Valencia

Is there any way to generate random numbers based on arbitrary real valued
functions? I am looking for something like random.gauss() but with natural
log and exponential functions.

Try with CRNG, it may have what you need, or be able to adapt it to
what you want. http://www.sbc.su.se/~per/crng/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,212
Messages
2,571,101
Members
47,695
Latest member
KayleneBee

Latest Threads

Top