Austin is naturally correct. But as (1 - uniform(x)) has the same
distribution as uniform(x)
his expression can be simplified without loss to
g e1 = -ln(uniform())
Nick
Austin Nichols
Jon--
The general approach is to take the cumulative distribution function
F(x) and solve for x in terms of F. Then replace F with uniform() and
you are done:
F=1-exp(-lambda*x)
1-F=exp(-lambda*x)
-lambda*x=ln(1-F)
x=-(1/lambda)*ln(1-F)
so for lambda=1, you can
g e1=-ln(1-uniform())
On Feb 19, 2008 9:02 PM, Jon Schwabish <[email protected]> wrote:
> Does anyone know how to create an exponential
> distribution with a mean of 1 to use as random
> numbers? I believe it's a tweak on exp=-ln(uniform()),
> but am not sure.
*
* 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/