MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Random sampling of an arbitrary distribution

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59792] Re: Random sampling of an arbitrary distribution
  • From: "dennis" <dwangsness at earthlink.net>
  • Date: Sun, 21 Aug 2005 03:51:42 -0400 (EDT)
  • References: <de6luq$cgp$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

I use the very simple method of evaluating the inverse CDF with a
uniform random value between 0 and 1 (Random[])

x:=inverseCDF[Random[]]

to generate random numbers.  If the inverse of the Cumulative
Distribution Function (CDF) is not available in closed form, which it
usually isn't, I use

inverseCDF = Interpolation[Table[{CDF[x],x},{x,xmin,xmax,dx}]]

As long as the range of x is finite you can generate random values over
the whole range.  If the range is infinite then you need to be
satisfied with a range of x  such as 0.000001 < CDF[x] < 0.999999 which
has always been good enough for me.  I usually set
interpolationOrder->1 because I once had a case where the default third
order interpolation produced a CDF that was not monotonically
increasing

With this method nothing ever needs to be thrown away in the process of
generting random samples and it seems fast.

Dennis


  • Prev by Date: Re: Re: [long] Mathematica 5.1 and memory: any garbage collection?
  • Next by Date: Re: Re: How to specify boundary conditions on all 4 sides of a plate for a steady state heat equation (PDE) using NDSolve? (Laplace equation)
  • Previous by thread: Re: Random sampling of an arbitrary distribution
  • Next by thread: Re: Random sampling of an arbitrary distribution