Re: generating random number
- To: mathgroup at smc.vnet.net
- Subject: [mg34470] Re: [mg34448] generating random number
- From: "Johannes Ludsteck" <johannes.ludsteck at wiwi.uni-regensburg.de>
- Date: Thu, 23 May 2002 03:32:09 -0400 (EDT)
- Organization: Universitaet Regensburg
- Sender: owner-wri-mathgroup at wolfram.com
Dear Ester,
if your random variable ist continuous,
the simplest way to obtain a random number distributed
according to an arbitrary PDF is to use the inversion
method: If F[x] is the distribution function of the random
variable x, an G[z] is the inverse of F
(the solution of z = F[x]),
the you obtain your pseudo random realization of x by
application of the inverse to a uniform random variable
G[Random[]]
in the same way you get an n-array of realizations with
Map[G,Table[Uniform[],{n}].
Here is the simple proof for the validity of the transformation:
If u ~ Uniform[0,1], then the
distribution function of u is H[u] = u
x ~ F[x];
v:= G[u];
P[v < z] = P[G[u] < z] = P[u < F[z]] = H[F[z]] = F[z]
The only one problem with this approach: you must
know the distribution function. If it is not possible to
integrate the density (PDF), you have to integrate it
numerically. If this is to slow, try generating a
table of the CDF, interpolate it and use the interpolation
instead of the distribution.
If this does not work or if your random variable is
discrete or mixed, have a look at the book
Luc Devroye: Non-Uniform Random Variable Generation.
Or use the package MathStatica (contained in the book)
Rose & Smith: Mathematical Statistics with Mathematica.
Best regards,
Johannes Ludsteck
On 22 May 2002, at 2:46, ester wrote:
>
> dear Sirs,
> my name is Ester Piedipalumbo and I am a post doc at the phisics dep. of
> Naples University.
> I would like to know if there is something for generating random number
> according an arbitary PDF (where arbitrary means that it is not standard,
> but I know, of cource)
> Thank a lot
> best regrds
> Ester
>
>
>
>
<><><><><><><><><><><><><><><><><><>
Johannes Ludsteck
Institut fuer Volkswirtschaftslehre
Lehrstuhl Prof. Dr. Moeller
Universitaet Regensburg
Universitaetsstrasse 31
93053 Regensburg
Tel +49/0941/943-2741