[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Sampling from a uniform distribution - suggestion
At 02:57 PM 6/20/2007, Jeph Herrin wrote -- in response to the
question from Tiago Pereira :
How about:
set obs 1000
gen X = uniform()*(60-10)+10
replace X = uniform()*(3000-2000)+2000 if mod(_n,6)==0
Originally, I thought of the same solution. Later, I realized you
can do it in one pass:
gen X = cond(mod(_n,6), uniform()*(60-10)+10 , uniform()*(3000-2000)+2000)
HTH
--David
*
* 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/