Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Producing random numbers from a kernel density


From   [email protected] (Roberto G. Gutierrez, StataCorp)
To   [email protected]
Subject   Re: st: Producing random numbers from a kernel density
Date   Thu, 09 Mar 2006 08:53:46 -0600

Peter Willem <[email protected]> asks:

> I am trying to draw random numbers from an arbitrary distribution. One idea
> that occurred to me was to use a kernel density estimator (-kdensity-), but
> I have no idea how to produce random numbers from the result. All
> suggestions are welcome.

Look into something called "rejection sampling" which does not require
the cumulative distribution function nor the ability to invert it to apply
the probability integral transform.  In fact, if you look up rejection
sampling on wikipedia, the description there is good enough to go from 
there.

You will have to be able to evaluate your kernel density at any given point
(not just at a grid), but at worst you just use linear interpolation between
grid points.

--Bobby
[email protected]
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index