On Fri, 3 Jan 2003, Philippe Grosjean wrote: > Prof. Brian Ripley wrote: > > >Do read the help page: > > > Ties are broken at random. The determination of ``tie'' assumes > > that the entries are probabilities. > > >and then don't blame your tools when you misuse them .... > > Yes, I did read this. So, I know why items are randomly selected in case of > `ties'. > But then, I reformulate the question: what are the criteria for deciding two > values are `ties' in max.col? > I know, the answer is certainly somewhere (at least in the code), however, > if someone knows it, it would help save time.
In maxcol.c, of course. #define RELTOL 1e-5 tol = RELTOL * fmax2(fabs(a), fabs(b)); > Thanks, > > Philippe Grosjean > > > On Thu, 2 Jan 2003, Philippe Grosjean wrote: > > > I suppose this is a general behavior with external function calls, so I do > > not post (yet) a specific bug report. Could someone explain this? > > > > a <- rep(1, 20) + rnorm(20, mean=0.00001, sd=0.0001) > > b <- embed(a, 3) > > # I want to know where the item in column 2 is greated than both col 1 and > 3 > > (peak) > > test1 <- max.col(b) == 2 > > # ... or I could use a less optimal code > > test2 <- apply(b, 1, max) == b[, 2] > > any(test1 != test2) # both are equivalent > > > > # but when numbers are very close > > a <- rep(1, 20) + rnorm(20, mean=0.0000001, sd=0.0000001) > > b <- embed(a, 3) > > test1 <- max.col(b) == 2 > > test2 <- apply(b, 1, max) == b[, 2] > > any(test1 != test2) # tests are now DIFFERENT! > > # Indeed, test2 is correct, and test1 suffers from wrong calculations due > > probably to rounding errors in max.col() > > No, to max.col working as documented. > > [Large waste of bandwidth deleted] > > -- > Brian D. Ripley, [EMAIL PROTECTED] > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272866 (PA) > Oxford OX1 3TG, UK Fax: +44 1865 272595 > > ______________________________________________ > [EMAIL PROTECTED] mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-devel > > > > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-devel