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   Marcello Pagano <>
Subject   Re: st: Producing random numbers from a kernel density
Date   Thu, 09 Mar 2006 08:09:23 -0500

Depends how many numbers you want to generate, how much accuracy you want etc., but a quick and (not so) dirty method is to (1) make sure you have a decent density estimate (such as eqprhistogram ;-) ) that is always non-negative and integrates to one, then (2) calculate the distribution function of this density at as fine a grid as you want, then (3) generate a uniform random number, and (4) use the probability integral transform (which says that your distribution function is uniformly distributed) to get your variate Voila.


Peter Willemé wrote:

Dear all,
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.

*   For searches and help try:

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