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