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: Mata order() indeterminate
From
[email protected] (Brendan Halpin)
To
[email protected]
Subject
st: Mata order() indeterminate
Date
Sun, 03 Nov 2013 02:07:33 +0000
I'm checking a simulation in Mata, and find that setting the seed to the
same value does not yield the same results on repeated runs. I've
tracked it down to the use of -order()- to sort a matrix, where there
are many ties. It appears that -order()- brings in indeterminacy in
dealing with ties, but from somewher other thanq the random-number system.
This snippet illustrates the issue:
mata:
x = range(1,10,1)
y = runiform(10,1):>0.5
for (i=1; i<=20; i++) {
rseed(12345)
x, x[order(y,1),]
}
end
Though x is unchanged, and the seed is set to the same value at each
pass, x[order(y,1)] changes.
While this is disturbing, I presume it is consistent with Stata policy
with regard to sorting indeterminacy.
How do I get repeatable sorting in this context?
Regards,
Brendan
--
Brendan Halpin, Head of Department, Sociology, University of Limerick, Ireland
Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F1-002 x 3147
mailto:[email protected] ULSociology on Facebook: http://on.fb.me/fjIK9t
http://teaching.sociology.ul.ie/bhalpin/wordpress twitter:@ULSociology
*
* 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/