Statalist The Stata Listserver


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

Re: st: Sampling from a uniform distribution - suggestion


From   Antoine Terracol <[email protected]>
To   [email protected]
Subject   Re: st: Sampling from a uniform distribution - suggestion
Date   Wed, 20 Jun 2007 21:13:59 +0200

Tiago,

try something like

gen x=3D(_n/6!=3Dround(_n/6,1))*(uniform()*(50)+10) + ///
(_n/6=3D=3Dround(_n/6,1))*(uniform()*(1000)+2000)

Antoine

[email protected] wrote:
> Dear statalisters,
>
> I would like to generate a random variable X (say 1000 new observations)
> wih an uniform distribution on the interval [10, 60].
>
> That=B4s ok (using Stata):
>
> set obs 1000
> gene X =3D  uniform()*(60-10)+10
>
> However, due to empirical observations from our laboratory experiments (t=
o
> produce a more realistic dataset), I have interest in adding one
> observation on the interval [2000, 3000] after 5 observations on the
> interval [10, 60]. Example:
>
> 28 42 12 56 41 2658 26 14 47 59 43 2157 ....
>
> Is there a simple way to generate such kind of observations using Stata?
>
> Thank you for all your help.
>
> Best regards,
>
> Tiago
>
>
>
> *
> *   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/
>

*
*   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