Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: generating random numbers without replacement
From
Michael McCulloch <[email protected]>
To
[email protected]
Subject
st: generating random numbers without replacement
Date
Fri, 24 May 2013 14:30:32 -0700
Hello,
I wish to generate random numbers between 1 and 5, without replacement. I have located the following Mata code, but have not yet learned Mata. Is it possible to rewrite this to create the variable a?
mata
a=J(100,1,.)
for(i=1;i<=100;i++) a[i,1]=i
a=a,runiform(100,1)
a=sort(a,2)
a
end
Best wishes,
Michael McCulloch, LAc MPH PhD
--
Pine Street Foundation, since 1989
124 Pine Street | San Anselmo | California | 94960-2674
P: (415) 407-1357 | F: (206) 338-2391 | http://www.PineStreetFoundation.org
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/