Random number generation from functions

CptPicard jpmnews at free.fr
Tue Nov 30 01:55:33 EST 2004


drs wrote:
> 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).



More information about the Python-list mailing list